summaryrefslogtreecommitdiff
path: root/src/bindings/mono
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-10-24 17:46:13 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-25 11:02:50 -0300
commit69261251a71f02111a046b97fbb2e520f8d1dc1e (patch)
tree6438939044c4dada47d3f09d5bf92349aa28d60e /src/bindings/mono
parentbcf27e35a276dd588211d4cec1d1a7c5fd7eedc0 (diff)
mono: implement dispose method based on dispose pattern
Summary: Fix CA1063, CA1816 ref T8400, T8419 Test Plan: meson setup -Dbindings=mono,cxx -Dmono-beta=true ninja test Reviewers: felipealmeida, brunobelo, YOhoho Reviewed By: YOhoho Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8419, T8400 Differential Revision: https://phab.enlightenment.org/D10460
Diffstat (limited to 'src/bindings/mono')
-rw-r--r--src/bindings/mono/efl_mono/GenericModel.cs2
-rw-r--r--src/bindings/mono/efl_mono/ItemFactory.cs2
-rw-r--r--src/bindings/mono/efl_mono/UserModel.cs8
-rw-r--r--src/bindings/mono/eina_mono/eina_accessor.cs1
-rw-r--r--src/bindings/mono/eo_mono/NativeModule.cs34
5 files changed, 35 insertions, 12 deletions
diff --git a/src/bindings/mono/efl_mono/GenericModel.cs b/src/bindings/mono/efl_mono/GenericModel.cs
index 1f92b8c..8bfa8ce 100644
--- a/src/bindings/mono/efl_mono/GenericModel.cs
+++ b/src/bindings/mono/efl_mono/GenericModel.cs
@@ -18,7 +18,7 @@ namespace Efl {
18/// </summary> 18/// </summary>
19/// <typeparam name="T">The type of the child model. It is the type used when adding/removing/getting items to this 19/// <typeparam name="T">The type of the child model. It is the type used when adding/removing/getting items to this
20/// model.</typeparam> 20/// model.</typeparam>
21public class GenericModel<T> : Efl.Object, Efl.IModel, IDisposable 21public class GenericModel<T> : Efl.Object, Efl.IModel
22{ 22{
23 private Efl.IModel model; 23 private Efl.IModel model;
24 24
diff --git a/src/bindings/mono/efl_mono/ItemFactory.cs b/src/bindings/mono/efl_mono/ItemFactory.cs
index 34791e1..a97401c 100644
--- a/src/bindings/mono/efl_mono/ItemFactory.cs
+++ b/src/bindings/mono/efl_mono/ItemFactory.cs
@@ -16,7 +16,7 @@ namespace Efl.Ui
16/// factory.Style().Bind("Name"); // The factory Style property is bound to the Name property for the given model. 16/// factory.Style().Bind("Name"); // The factory Style property is bound to the Name property for the given model.
17/// </code> 17/// </code>
18/// </summary> 18/// </summary>
19public class ItemFactory<T> : Efl.Ui.LayoutFactory, IDisposable 19public class ItemFactory<T> : Efl.Ui.LayoutFactory
20{ 20{
21 /// <summary>Creates a new factory. 21 /// <summary>Creates a new factory.
22 /// </summary> 22 /// </summary>
diff --git a/src/bindings/mono/efl_mono/UserModel.cs b/src/bindings/mono/efl_mono/UserModel.cs
index 1116dfc..a235a3a 100644
--- a/src/bindings/mono/efl_mono/UserModel.cs
+++ b/src/bindings/mono/efl_mono/UserModel.cs
@@ -67,7 +67,7 @@ internal class ModelHelper
67/// </summary> 67/// </summary>
68/// <typeparam name="T">The enclosed C# model class with the properties to be added to the native model.</typeparam> 68/// <typeparam name="T">The enclosed C# model class with the properties to be added to the native model.</typeparam>
69[Efl.Eo.BindingEntity] 69[Efl.Eo.BindingEntity]
70public class UserModel<T> : Efl.MonoModelInternal, IDisposable 70public class UserModel<T> : Efl.MonoModelInternal
71{ 71{
72 /// <summary> 72 /// <summary>
73 /// Creates a new root model. 73 /// Creates a new root model.
@@ -85,12 +85,6 @@ public class UserModel<T> : Efl.MonoModelInternal, IDisposable
85 } 85 }
86 } 86 }
87 87
88 /// <summary>Disposes of this instance.</summary>
89 ~UserModel()
90 {
91 Dispose(false);
92 }
93
94 /// <summary>Adds a new child to the model wrapping the properties of <c>o</c> 88 /// <summary>Adds a new child to the model wrapping the properties of <c>o</c>
95 /// 89 ///
96 /// <para>Reflection is used to instantiate a new <see cref="Efl.IModel" />-based class for this child and 90 /// <para>Reflection is used to instantiate a new <see cref="Efl.IModel" />-based class for this child and
diff --git a/src/bindings/mono/eina_mono/eina_accessor.cs b/src/bindings/mono/eina_mono/eina_accessor.cs
index 6c939bc..64b4216 100644
--- a/src/bindings/mono/eina_mono/eina_accessor.cs
+++ b/src/bindings/mono/eina_mono/eina_accessor.cs
@@ -95,6 +95,7 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
95 public void Dispose() 95 public void Dispose()
96 { 96 {
97 Dispose(true); 97 Dispose(true);
98 GC.SuppressFinalize(this);
98 } 99 }
99 100
100 /// <summary>Disposes of this wrapper, releasing the native accessor if 101 /// <summary>Disposes of this wrapper, releasing the native accessor if
diff --git a/src/bindings/mono/eo_mono/NativeModule.cs b/src/bindings/mono/eo_mono/NativeModule.cs
index fd3b315..ad9cc60 100644
--- a/src/bindings/mono/eo_mono/NativeModule.cs
+++ b/src/bindings/mono/eo_mono/NativeModule.cs
@@ -22,6 +22,7 @@ namespace Efl.Eo
22public partial class NativeModule : IDisposable 22public partial class NativeModule : IDisposable
23{ 23{
24 private Lazy<IntPtr> module; 24 private Lazy<IntPtr> module;
25 private bool disposed = false;
25 26
26 ///<summary>Lazily tries to load the module with the given name.</summary> 27 ///<summary>Lazily tries to load the module with the given name.</summary>
27 ///<param name="libName">The name of the module to load.</param> 28 ///<param name="libName">The name of the module to load.</param>
@@ -43,12 +44,39 @@ public partial class NativeModule : IDisposable
43 } 44 }
44 } 45 }
45 46
46 ///<summary>Unload and released the handle to the wrapped module.</summary> 47 /// <summary>Finalizer to be called from the Garbage Collector.</summary>
48 ~NativeModule()
49 {
50 Dispose(false);
51 }
52
53 /// <summary>Unload and released the handle to the wrapped module.</summary>
47 public void Dispose() 54 public void Dispose()
48 { 55 {
49 UnloadLibrary(module.Value); 56 Dispose(true);
50 module = null; 57 GC.SuppressFinalize(this);
51 } 58 }
59
60 /// <summary>Unload and released the handle to the wrapped module.</summary>
61 protected virtual void Dispose(bool disposing)
62 {
63 if (disposed)
64 {
65 return;
66 }
67
68 if (disposing)
69 {
70 module = null;
71 }
72
73 if (module.IsValueCreated)
74 {
75 UnloadLibrary(module.Value);
76 }
77
78 disposed = true;
79 }
52} 80}
53 81
54} 82}