lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [36/50] [abbrv] lucenenet git commit: Lucene.Net.Analysis.Common.Analysis.Util.AbstractAnalysisFactory: Added GetCulture() method to allow passing a CultureInfo object to a factory using either the string representation of the culture or its LCID
Date Wed, 15 Mar 2017 23:50:18 GMT
Lucene.Net.Analysis.Common.Analysis.Util.AbstractAnalysisFactory: Added GetCulture() method
to allow passing a CultureInfo object to a factory using either the string representation
of the culture or its LCID


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

Branch: refs/heads/api-work
Commit: 26d6c3f53e2f5fda2b1eaa631584fc84b15455eb
Parents: d2ceebe
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Wed Mar 15 20:50:28 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Wed Mar 15 20:50:28 2017 +0700

----------------------------------------------------------------------
 .../Analysis/Util/AbstractAnalysisFactory.cs    | 36 ++++++++++++++++++++
 1 file changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/26d6c3f5/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
index f193387..639e3f9 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/AbstractAnalysisFactory.cs
@@ -2,6 +2,7 @@
 using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
+using System.Globalization;
 using System.IO;
 using System.Linq;
 using System.Text;
@@ -318,6 +319,41 @@ namespace Lucene.Net.Analysis.Util
         }
 
         /// <summary>
+        /// Gets a <see cref="CultureInfo"/> value of the specified argument key <paramref
name="name"/>.
+        /// <para/>
+        /// To specify the invariant culture, pass the string <c>"invariant"</c>.
To specify
+        /// the culture using the <see cref="CultureInfo.LCID"/>, pass the value as
an <see cref="int"/>.
+        /// <para/>
+        /// LUCENENET specific
+        /// </summary>
+        protected CultureInfo GetCulture(IDictionary<string, string> args, string name,
CultureInfo defaultVal)
+        {
+            string culture;
+            if (args.TryGetValue(name, out culture))
+            {
+                args.Remove(name);
+                try
+                {
+                    if (culture.Equals("invariant"))
+                    {
+                        return CultureInfo.InvariantCulture;
+                    }
+                    return new CultureInfo(culture);
+                }
+                catch (Exception e)
+                {
+                    throw new System.ArgumentException("Configuration Error: '" + name +
"' can not be parsed in " + this.GetType().Name, e);
+                }
+            }
+            int lcid;
+            if ((lcid = GetInt32(args, name, int.MinValue)) != int.MinValue)
+            {
+                return new CultureInfo(lcid);
+            }
+            return defaultVal;
+        }
+
+        /// <summary>
         /// Returns as <see cref="CharArraySet"/> from wordFiles, which
         /// can be a comma-separated list of filenames
         /// </summary>


Mime
View raw message