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


C# IProvider.GetNextRecord方法代码示例

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


在下文中一共展示了IProvider.GetNextRecord方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ();
            }
        }
开发者ID:WimObiwan,项目名称:FxGqlC,代码行数:71,代码来源:IntoProvider.cs


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