You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/07/13 18:38:25 UTC

[1/2] lucenenet git commit: Lucene.Net.Support.Search.ReferenceManagerExtensions: Renamed AcquireContext() to GetContext(), closes #207 [Forced Update!]

Repository: lucenenet
Updated Branches:
  refs/heads/master 9c5085c4b -> e694ee94f (forced update)


Lucene.Net.Support.Search.ReferenceManagerExtensions: Renamed AcquireContext() to GetContext(), closes #207


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

Branch: refs/heads/master
Commit: 559efc75e259698360af3e632fad5ad94447ae03
Parents: 6f51ab5
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 14 01:21:11 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 14 01:37:49 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/559efc75/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs b/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
index 2629398..b8bde10 100644
--- a/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
+++ b/src/Lucene.Net/Support/Search/ReferenceManagerExtensions.cs
@@ -28,7 +28,7 @@
         /// <para/>
         /// <code>
         /// var searcherManager = new SearcherManager(indexWriter, true, null);
-        /// using (var context = searcherManager.AcquireContext())
+        /// using (var context = searcherManager.GetContext())
         /// {
         ///     IndexSearcher searcher = context.Reference;
         ///     
@@ -38,8 +38,10 @@
         /// </summary>
         /// <typeparam name="T">The reference type</typeparam>
         /// <param name="referenceManager">this <see cref="ReferenceManager{G}"/></param>
-        /// <returns>A <see cref="ReferenceContext{T}"/> instance that holds the <see cref="ReferenceContext{T}.Reference"/> and ensures it is released properly when <see cref="ReferenceContext{T}.Dispose()"/> is called.</returns>
-        public static ReferenceContext<T> AcquireContext<T>(this ReferenceManager<T> referenceManager) where T : class
+        /// <returns>A <see cref="ReferenceContext{T}"/> instance that holds the 
+        /// <see cref="ReferenceContext{T}.Reference"/> and ensures it is released properly 
+        /// when <see cref="ReferenceContext{T}.Dispose()"/> is called.</returns>
+        public static ReferenceContext<T> GetContext<T>(this ReferenceManager<T> referenceManager) where T : class
         {
             return new ReferenceContext<T>(referenceManager);
         }


[2/2] lucenenet git commit: API: Lucene.Net.Support.Document: Added extension methods to make casting to the correct field type simpler.

Posted by ni...@apache.org.
API: Lucene.Net.Support.Document: Added extension methods to make casting to the correct field type simpler.


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

Branch: refs/heads/master
Commit: e694ee94f57ab8ceff5747760f99cd9b8505aa4c
Parents: 559efc7
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Jul 14 01:34:03 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Jul 14 01:38:03 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net/Document/Document.cs             |  2 +-
 src/Lucene.Net/Lucene.Net.csproj                |  1 +
 .../Support/Document/DocumentExtensions.cs      | 39 ++++++++++++++++++++
 3 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e694ee94/src/Lucene.Net/Document/Document.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Document/Document.cs b/src/Lucene.Net/Document/Document.cs
index d19f874..e67946f 100644
--- a/src/Lucene.Net/Document/Document.cs
+++ b/src/Lucene.Net/Document/Document.cs
@@ -192,7 +192,7 @@ namespace Lucene.Net.Documents
 
         /// <summary>
         /// Returns an array of <see cref="IIndexableField"/>s with the given name.
-        /// this method returns an empty array when there are no
+        /// This method returns an empty array when there are no
         /// matching fields. It never returns <c>null</c>.
         /// </summary>
         /// <param name="name"> the name of the field </param>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e694ee94/src/Lucene.Net/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj
index ff96872..d2b8e6e 100644
--- a/src/Lucene.Net/Lucene.Net.csproj
+++ b/src/Lucene.Net/Lucene.Net.csproj
@@ -394,6 +394,7 @@
     <Compile Include="Index\TwoStoredFieldsConsumers.cs" />
     <Compile Include="Index\UpgradeIndexMergePolicy.cs" />
     <Compile Include="LucenePackage.cs" />
+    <Compile Include="Support\Document\DocumentExtensions.cs" />
     <Compile Include="Support\IO\Compression\LZOCompressor.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Search\AutomatonQuery.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e694ee94/src/Lucene.Net/Support/Document/DocumentExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Document/DocumentExtensions.cs b/src/Lucene.Net/Support/Document/DocumentExtensions.cs
new file mode 100644
index 0000000..c04dc21
--- /dev/null
+++ b/src/Lucene.Net/Support/Document/DocumentExtensions.cs
@@ -0,0 +1,39 @@
+using Lucene.Net.Index;
+using System.Linq;
+
+namespace Lucene.Net.Documents
+{
+    /// <summary>
+    /// Extension methods to the <see cref="Document"/> class.
+    /// </summary>
+    public static class DocumentExtensions
+    {
+        /// <summary>
+        /// Returns a field with the given name if any exist in this document cast to type <typeparam name="T"/>, or
+        /// <c>null</c>. If multiple fields exists with this name, this method returns the
+        /// first value added.
+        /// <para/>
+        /// LUCENENET specific
+        /// </summary>
+        /// <exception cref="InvalidCastException">If the field type cannot be cast to <typeparam name="T"/>.</exception>
+        public static T GetField<T>(this Document document, string name) where T : IIndexableField
+        {
+            return (T)document.GetField(name);
+        }
+
+        /// <summary>
+        /// Returns an array of <see cref="IIndexableField"/>s with the given name, cast to type <typeparam name="T"/>.
+        /// This method returns an empty array when there are no
+        /// matching fields. It never returns <c>null</c>.
+        /// <para/>
+        /// LUCENENET specific
+        /// </summary>
+        /// <param name="name"> the name of the field </param>
+        /// <returns> a <see cref="T:IndexableField[]"/> array </returns>
+        /// <exception cref="InvalidCastException">If the field type cannot be cast to <typeparam name="T"/>.</exception>
+        public static T[] GetFields<T>(this Document document, string name) where T : IIndexableField
+        {
+            return document.GetFields(name).Cast<T>().ToArray();
+        }
+    }
+}