lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [3/6] lucenenet git commit: Cannot reference "this" in ctor redirects
Date Fri, 07 Nov 2014 05:39:14 GMT
Cannot reference "this" in ctor redirects


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/f6387ca3
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/f6387ca3
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/f6387ca3

Branch: refs/heads/master
Commit: f6387ca3443cee7aa09c88245c32d616ec1b2cc8
Parents: 4c20661
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Fri Nov 7 07:34:56 2014 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Fri Nov 7 07:34:56 2014 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Queries/TermsFilter.cs | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f6387ca3/src/Lucene.Net.Queries/TermsFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/TermsFilter.cs b/src/Lucene.Net.Queries/TermsFilter.cs
index 1585cdd..5731ec1 100644
--- a/src/Lucene.Net.Queries/TermsFilter.cs
+++ b/src/Lucene.Net.Queries/TermsFilter.cs
@@ -57,19 +57,16 @@ namespace Lucene.Net.Queries
         /// can contain duplicate terms and multiple fields.
         /// </summary>
         public TermsFilter(List<Term> terms)
-            : this(new FieldAndTermEnumAnonymousInnerClassHelper(this, terms), terms.Count)
+            : this(new FieldAndTermEnumAnonymousInnerClassHelper(terms), terms.Count)
         {
         }
 
         private class FieldAndTermEnumAnonymousInnerClassHelper : FieldAndTermEnum
-        {
-            private readonly TermsFilter outerInstance;
-
+        {            
             private IList<Term> terms;
 
-            public FieldAndTermEnumAnonymousInnerClassHelper(TermsFilter outerInstance, List<Term>
terms)
+            public FieldAndTermEnumAnonymousInnerClassHelper(List<Term> terms)
             {
-                this.outerInstance = outerInstance;
                 this.terms = terms;
                 terms.Sort();
                 iter = terms.GetEnumerator();
@@ -94,20 +91,17 @@ namespace Lucene.Net.Queries
         /// a single field.
         /// </summary>
         public TermsFilter(string field, List<BytesRef> terms)
-            : this(new FieldAndTermEnumAnonymousInnerClassHelper2(this, field, terms), terms.Count)
+            : this(new FieldAndTermEnumAnonymousInnerClassHelper2(field, terms), terms.Count)
         {
         }
 
         private class FieldAndTermEnumAnonymousInnerClassHelper2 : FieldAndTermEnum
         {
-            private readonly TermsFilter outerInstance;
-
             private IList<BytesRef> terms;
 
-            public FieldAndTermEnumAnonymousInnerClassHelper2(TermsFilter outerInstance,
string field, List<BytesRef> terms)
+            public FieldAndTermEnumAnonymousInnerClassHelper2(string field, List<BytesRef>
terms)
                 : base(field)
             {
-                this.outerInstance = outerInstance;
                 this.terms = terms;
                 terms.Sort();
                 iter = terms.GetEnumerator();
@@ -147,6 +141,8 @@ namespace Lucene.Net.Queries
 
         private TermsFilter(FieldAndTermEnum iter, int length)
         {
+            iter.OuterInstance = this; // .NET specific, since "this" can't be used in ctor
redirection
+
             // TODO: maybe use oal.index.PrefixCodedTerms instead?
             // If number of terms is more than a few hundred it
             // should be a win
@@ -382,15 +378,17 @@ namespace Lucene.Net.Queries
 
         private abstract class FieldAndTermEnum
         {
-            protected internal string field;
+            public TermsFilter OuterInstance { get; internal set; }
+
+            protected string field;
 
             public abstract BytesRef Next();
 
-            public FieldAndTermEnum()
+            protected FieldAndTermEnum()
             {
             }
 
-            public FieldAndTermEnum(string field)
+            protected FieldAndTermEnum(string field)
             {
                 this.field = field;
             }


Mime
View raw message