lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [lucenenet] 02/07: Lucene.Net.Analysis.Analyzer: Implemented dispose pattern
Date Sat, 13 Jul 2019 17:52:04 GMT
This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit a4e796d98ed7cd3f1853a9b717e42e6986d5b3e7
Author: Shad Storhaug <shad@shadstorhaug.com>
AuthorDate: Sat Jul 13 00:14:45 2019 +0700

    Lucene.Net.Analysis.Analyzer: Implemented dispose pattern
---
 src/Lucene.Net/Analysis/Analyzer.cs | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/Lucene.Net/Analysis/Analyzer.cs b/src/Lucene.Net/Analysis/Analyzer.cs
index f0c2c9d..1120fd2 100644
--- a/src/Lucene.Net/Analysis/Analyzer.cs
+++ b/src/Lucene.Net/Analysis/Analyzer.cs
@@ -365,13 +365,26 @@ namespace Lucene.Net.Analysis
         }
 
         /// <summary>
-        /// Frees persistent resources used by this <see cref="Analyzer"/> </summary>
-        public virtual void Dispose()
+        /// Frees persistent resources used by this <see cref="Analyzer"/> 
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        /// <summary>
+        /// Frees persistent resources used by this <see cref="Analyzer"/> 
+        /// </summary>
+        protected virtual void Dispose(bool disposing)
         {
-            if (storedValue != null)
+            if (disposing)
             {
-                storedValue.Dispose();
-                storedValue = null;
+                if (storedValue != null)
+                {
+                    storedValue.Dispose();
+                    storedValue = null;
+                }
             }
         }
 


Mime
View raw message