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