本文整理汇总了C#中IProvider.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# IProvider.Initialize方法的具体用法?C# IProvider.Initialize怎么用?C# IProvider.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProvider
的用法示例。
在下文中一共展示了IProvider.Initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DumpProviderToStream
public static void DumpProviderToStream(IProvider provider, TextWriter outputWriter, GqlQueryState gqlQueryState,
string columnDelimiter, GqlEngineState.HeadingEnum heading, int autoSize,
FileOptionsIntoClause.FormatEnum format,
CultureInfo cultureInfo)
{
try {
provider.Initialize (gqlQueryState);
List<string[]> list = new List<string[]> ();
if (heading != GqlEngineState.HeadingEnum.Off) {
ColumnName[] columnTitles = provider.GetColumnNames ();
if (columnTitles.Length > 0) {
string[] columnTitleStrings = columnTitles.Select (p => p.ToStringWithoutBrackets ()).ToArray ();
list.Add (columnTitleStrings);
if (heading == GqlEngineState.HeadingEnum.OnWithRule) {
string[] columnTitlesRule = new string[columnTitles.Length];
for (int i = 0; i < columnTitles.Length; i++)
columnTitlesRule [i] = new string ('=', columnTitleStrings [i].ToString ().Length);
list.Add (columnTitlesRule);
}
}
}
for (int record = 0; (autoSize == -1 || record < autoSize); record++) {
try {
if (!provider.GetNextRecord ())
break;
} catch (WarningException x) {
gqlQueryState.Warnings.Add (new LineIgnoredException (x));
record--;
continue;
}
list.Add (provider.Record.Columns.Select (p => p.ToString ()).ToArray ());
}
FormatColumnsFunction formatColumnListFunction;
if (autoSize == 0) {
if (format == FileOptionsIntoClause.FormatEnum.Csv)
formatColumnListFunction = new FormatCsvFunction (columnDelimiter);
else
formatColumnListFunction = new FormatColumnListFunction (columnDelimiter);
} else {
int[] max = new int[list [0].Length];
foreach (string[] item in list) {
for (int col = 0; col < max.Length; col++)
max [col] = Math.Max (item [col].Length, max [col]);
}
Type[] types = provider.GetColumnTypes ();
for (int col = 0; col < max.Length; col++)
if (types [col] != typeof(DataString))
max [col] = -max [col];
formatColumnListFunction = new FormatColumnListFunction (columnDelimiter, max);
}
foreach (var item in list) {
outputWriter.WriteLine (formatColumnListFunction.Evaluate (item));
}
do {
try {
if (!provider.GetNextRecord ())
break;
outputWriter.WriteLine (formatColumnListFunction.Evaluate (provider.Record.Columns.Select (p => p.ToDataString (cultureInfo).Value)));
} catch (WarningException x) {
gqlQueryState.Warnings.Add (new LineIgnoredException (x));
}
} while (true);
} finally {
provider.Uninitialize ();
}
}
示例2: SetNextProvider
public bool SetNextProvider()
{
if (provider != null) {
provider.Uninitialize ();
provider = null;
}
currentFile++;
if (currentFile >= files.Length)
return false;
provider = FileProviderFactory.Get (files [currentFile], skip);
provider.Initialize (gqlQueryState);
return true;
}