当前位置: 首页>>代码示例>>C#>>正文


C# Index.Configure方法代码示例

本文整理汇总了C#中Index.Configure方法的典型用法代码示例。如果您正苦于以下问题:C# Index.Configure方法的具体用法?C# Index.Configure怎么用?C# Index.Configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Index的用法示例。


在下文中一共展示了Index.Configure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Search

        // <summary>
        /// Searches using a (command line) user interface arguments
        /// </summary>
        public static void Search(Index indexObject, IEnumerable<string> args, SearchFilter handler)
        {
            string index = null;
            string queries = null;
            string result = null;
            string names = null;
            bool help = false;
            bool disthist = true;
            bool force = false;
            int showmaxres = 30;
            string indexclass = null;
            var config = new Dictionary<string, object> ();

            OptionSet ops = new OptionSet () {
                { "i|index=",   v => index = v },
                { "q|queries=",  v => queries = v },
                { "r|result=", v => result = v },
                { "force|f", v => force = true},
                { "hidehist", v => disthist = false },
                { "names=", v => names = v},
                { "showmaxres=", v => showmaxres = int.Parse (v) },
                { "indexclass=", v => indexclass = v},
                { "h|?|help",   v => help = true },
                { "config=", delegate(string v) {
                var split = v.Split (':');
                if (split.Length != 2) {
                    throw new ArgumentNullException ("config command options should be in format --config key:value ");
                }
                config.Add (split [0], split [1]);
            }
                }
            };
            List<string> extraArgs = ops.Parse (args);

            if (help) {
                Console.WriteLine ("Usage: ");
                Console.WriteLine ("{0} search --index indexname --queries queriesfile [--result resname] [index args] [environ args]", Environment.GetCommandLineArgs () [0]);
                return;
            }
            if (result == null) {
                force = true;
            }
            if ((indexObject == null && index == null) || queries == null) {
                Console.WriteLine ("Usage: ");
                Console.WriteLine ("{0} search --index indexname --queries queriesfile [--result resname] [index args] [environ args]", Environment.GetCommandLineArgs () [0]);
                throw new ArgumentException (String.Format ("Some required arguments wasn't specified index: {0}, queries: {0}", index, queries));
            }
            if (force || !File.Exists (result)) {
                Console.WriteLine ("XXXXXXXXXX index: {0}, indexclass: {1}", index, indexclass);
                if (indexObject == null) {
                    indexObject = IndexLoader.Load (index, indexclass, config);
                } else {
                    index = String.Format ("<memory:{0}>", indexObject.ToString ());
                }
                indexObject.Configure (extraArgs);
                var searchOps = new ShellSearchOptions (queries, index, names, result, showmaxres, disthist, handler);
                var qstream = new QueryStream (queries);
                Search (indexObject, qstream.Iterate (), searchOps, extraArgs);
            } else {
                Console.WriteLine ("skipping search command since result file already exists. File: {0}", result);
            }
        }
开发者ID:Pako125,项目名称:natix,代码行数:65,代码来源:Commands.cs


注:本文中的Index.Configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。