/// <summary>Observe the ownership state of an Eo wrapper and control its life-cycle.</summary>
publicclassWrapperSupervisor
{
privateSystem.WeakReferenceweakRef;
#pragmawarningdisableCS0414
privateEfl.Eo.IWrappersharedRef;
#pragmawarningrestoreCS0414
privateEventDictionaryeoEvents;
/// <summary>Create a new supervisor for the given.</summary>
/// <param name="obj">Efl object to be supervised.</param>
publicWrapperSupervisor(Efl.Eo.IWrapperobj)
{
weakRef=newWeakReference(obj);
sharedRef=null;
eoEvents=newEventDictionary();
}
/// <summary>Efl object being supervised.</summary>
publicEfl.Eo.IWrapperTarget
{
get
{
return(Efl.Eo.IWrapper)weakRef.Target;
}
}
/// <summary>Dictionary that holds the events related with the supervised object.</summary>
publicEventDictionaryEoEvents
{
get
{
returneoEvents;
}
}
/// <summary>To be called when the object is uniquely owned by C#, removing its strong reference and making it available to garbage collection.</summary>
publicvoidMakeUnique()
{
sharedRef=null;
}
/// <summary>To be called when the object is owned in the native library too, adding a strong reference to it and making it unavailable for garbage collection.</summary>
publicvoidMakeShared()
{
if(this.Target==null)
thrownewInvalidOperationException("Tried to make a null reference shared.");