Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E63D9200CBD for ; Thu, 22 Jun 2017 07:25:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E4EB3160BD5; Thu, 22 Jun 2017 05:25:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4B83C160C08 for ; Thu, 22 Jun 2017 07:25:06 +0200 (CEST) Received: (qmail 82105 invoked by uid 500); 22 Jun 2017 05:25:05 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 81365 invoked by uid 99); 22 Jun 2017 05:25:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jun 2017 05:25:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 16A94E969D; Thu, 22 Jun 2017 05:25:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nightowl888@apache.org To: commits@lucenenet.apache.org Date: Thu, 22 Jun 2017 05:25:31 -0000 Message-Id: <06cd99e18ebd40608a63197633729093@git.apache.org> In-Reply-To: <231e7073b9444cdc955d02db32d1edee@git.apache.org> References: <231e7073b9444cdc955d02db32d1edee@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [30/38] lucenenet git commit: Lucene.Net.Search.MultiPhraseQuery: Implemented IEnumerable so collection initializer can be used and added documentation to show usage of collection initializer archived-at: Thu, 22 Jun 2017 05:25:08 -0000 Lucene.Net.Search.MultiPhraseQuery: Implemented IEnumerable so collection initializer can be used and added documentation to show usage of collection initializer Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/86873c5a Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/86873c5a Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/86873c5a Branch: refs/heads/master Commit: 86873c5aa279831d336a7487819e3284682f8083 Parents: 56d6d6d Author: Shad Storhaug Authored: Wed Jun 21 23:53:22 2017 +0700 Committer: Shad Storhaug Committed: Thu Jun 22 00:13:02 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net/Search/MultiPhraseQuery.cs | 37 +++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/86873c5a/src/Lucene.Net/Search/MultiPhraseQuery.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Search/MultiPhraseQuery.cs b/src/Lucene.Net/Search/MultiPhraseQuery.cs index 5e2491d..ea93931 100644 --- a/src/Lucene.Net/Search/MultiPhraseQuery.cs +++ b/src/Lucene.Net/Search/MultiPhraseQuery.cs @@ -42,6 +42,7 @@ namespace Lucene.Net.Search using TermsEnum = Lucene.Net.Index.TermsEnum; using TermState = Lucene.Net.Index.TermState; using ToStringUtils = Lucene.Net.Util.ToStringUtils; + using System.Collections; /// /// is a generalized version of , with an added @@ -51,11 +52,25 @@ namespace Lucene.Net.Search /// on the term "Microsoft", then find all terms that have "app" as /// prefix using MultiFields.GetFields(IndexReader).GetTerms(string), and use /// to add them to the query. + /// + /// Collection initializer note: To create and populate a + /// in a single statement, you can use the following example as a guide: + /// + /// + /// var multiPhraseQuery = new MultiPhraseQuery() { + /// new Term("field", "microsoft"), + /// new Term("field", "office") + /// }; + /// + /// Note that as long as you specify all of the parameters, you can use either + /// , , or + /// as the method to use to initialize. If there are multiple parameters, each parameter set + /// must be surrounded by curly braces. /// #if FEATURE_SERIALIZABLE [Serializable] #endif - public class MultiPhraseQuery : Query + public class MultiPhraseQuery : Query, IEnumerable // LUCENENET specific - implemented IEnumerable, which allows for use of collection initializer. See: https://stackoverflow.com/a/9195144 { private string field; private List termArrays = new List(); @@ -503,6 +518,26 @@ namespace Lucene.Net.Search } return true; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// An enumerator that can be used to iterate through the collection. + // LUCENENET specific + public IEnumerator GetEnumerator() + { + return termArrays.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the . + /// + /// An enumerator that can be used to iterate through the collection. + // LUCENENET specific + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } } ///