/// </summary>
/// <typeparam name="T">The type of the child model. It is the type used when adding/removing/getting items to this
/// model.</typeparam>
-public class GenericModel<T> : Efl.Object, Efl.IModel, IDisposable
+public class GenericModel<T> : Efl.Object, Efl.IModel
{
private Efl.IModel model;
/// factory.Style().Bind("Name"); // The factory Style property is bound to the Name property for the given model.
/// </code>
/// </summary>
-public class ItemFactory<T> : Efl.Ui.LayoutFactory, IDisposable
+public class ItemFactory<T> : Efl.Ui.LayoutFactory
{
/// <summary>Creates a new factory.
/// </summary>
/// </summary>
/// <typeparam name="T">The enclosed C# model class with the properties to be added to the native model.</typeparam>
[Efl.Eo.BindingEntity]
-public class UserModel<T> : Efl.MonoModelInternal, IDisposable
+public class UserModel<T> : Efl.MonoModelInternal
{
/// <summary>
/// Creates a new root model.
}
}
- /// <summary>Disposes of this instance.</summary>
- ~UserModel()
- {
- Dispose(false);
- }
-
/// <summary>Adds a new child to the model wrapping the properties of <c>o</c>
///
/// <para>Reflection is used to instantiate a new <see cref="Efl.IModel" />-based class for this child and
public void Dispose()
{
Dispose(true);
+ GC.SuppressFinalize(this);
}
/// <summary>Disposes of this wrapper, releasing the native accessor if
public partial class NativeModule : IDisposable
{
private Lazy<IntPtr> module;
+ private bool disposed = false;
///<summary>Lazily tries to load the module with the given name.</summary>
///<param name="libName">The name of the module to load.</param>
}
}
- ///<summary>Unload and released the handle to the wrapped module.</summary>
+ /// <summary>Finalizer to be called from the Garbage Collector.</summary>
+ ~NativeModule()
+ {
+ Dispose(false);
+ }
+
+ /// <summary>Unload and released the handle to the wrapped module.</summary>
public void Dispose()
{
- UnloadLibrary(module.Value);
- module = null;
+ Dispose(true);
+ GC.SuppressFinalize(this);
}
+
+ /// <summary>Unload and released the handle to the wrapped module.</summary>
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ module = null;
+ }
+
+ if (module.IsValueCreated)
+ {
+ UnloadLibrary(module.Value);
+ }
+
+ disposed = true;
+ }
}
}