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


C# ParserContext.GetAllLines方法代码示例

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


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

示例1: Parse

        public string[][] Parse(string csvData)
        {
            var context = new ParserContext();

            string[] lines = csvData.Split('\n');

            ParserState currentState = ParserState.LineStartState;
            foreach (string next in lines)
            {
                foreach (char ch in next)
                {
                    switch (ch)
                    {
                        case CommaCharacter:
                            currentState = currentState.Comma(context);
                            break;
                        case QuoteCharacter:
                            currentState = currentState.Quote(context);
                            break;
                        default:
                            currentState = currentState.AnyChar(ch, context);
                            break;
                    }
                }
                currentState = currentState.EndOfLine(context);
            }
            List<string[]> allLines = context.GetAllLines();
            return allLines.ToArray();
        }
开发者ID:mraue,项目名称:minijam_june_2015,代码行数:29,代码来源:CsvParser.cs

示例2: Parse

        public string[][] Parse(TextReader reader)
        {
            var context = new ParserContext();

            ParserState currentState = ParserState.LineStartState;
            string next;
            while ((next = reader.ReadLine()) != null)
            {
                foreach (char ch in next)
                {
                    switch (ch)
                    {
                        case CommaCharacter:
                            currentState = currentState.Comma(context);
                            break;
                        case QuoteCharacter:
                            currentState = currentState.Quote(context);
                            break;
                        default:
                            currentState = currentState.AnyChar(ch, context);
                            break;
                    }
                }
                currentState = currentState.EndOfLine(context);
            }
            List<string[]> allLines = context.GetAllLines();
            return allLines.ToArray();
        }
开发者ID:sdpatro,项目名称:doc-onlook,代码行数:28,代码来源:CsvParser.cs

示例3: Parse

    public string[][] Parse(TextReader reader)
    {
        var context = new ParserContext();
        if (MaxColumnsToRead != 0)
            context.MaxColumnsToRead = MaxColumnsToRead;

        ParserState currentState = ParserState.LineStartState;
        string next;
        while ((next = reader.ReadLine()) != null)
        {
            foreach (char ch in next)
            {
                switch (ch)
                {
                    case CommaCharacter:
                        currentState = currentState.Comma(context);
                        break;
                    case QuoteCharacter:
                        currentState = currentState.Quote(context);
                        break;
                    default:
                        currentState = currentState.AnyChar(ch, context);
                        break;
                }
            }
            currentState = currentState.EndOfLine(context);
        }
        List<string[]> allLines = context.GetAllLines();
        if (TrimTrailingEmptyLines && allLines.Count > 0)
        {
            bool isEmpty = true;
            for (int i = allLines.Count - 1; i >= 0; i--)
            {
        // ReSharper disable RedundantAssignment
                isEmpty = true;
        // ReSharper restore RedundantAssignment
                for (int j = 0; j < allLines[i].Length; j++)
                {
                    if (!String.IsNullOrEmpty(allLines[i][j]))
                    {
                        isEmpty = false;
                        break;
                    }
                }
                if (!isEmpty)
                {
                    if (i < allLines.Count - 1)
                        allLines.RemoveRange(i + 1, allLines.Count - i - 1);
                    break;
                }
            }
            if (isEmpty)
                allLines.RemoveRange(0, allLines.Count);
        }
        return allLines.ToArray();
    }
开发者ID:Rgallouet,项目名称:Blue-Star,代码行数:56,代码来源:CsvParser2.cs

示例4: Parse

		public string[][] Parse(string csvData)
		{
			var context = new ParserContext();

			// Handle both Windows and Mac line endings
			var lines = Regex.Split(csvData, "\n|\r\n");

			ParserState currentState = ParserState.LineStartState;
			for (int i = 0; i < lines.Length; i++) {
				var next = lines [i];

				// Skip empty entries
				if (next.Length == 0)
				{
					continue;
				}

				for (int j = 0; j < next.Length; j++) {
					var ch = next [j];

					switch (ch) {
					case CommaCharacter:
						currentState = currentState.Comma (context);
						break;
					case QuoteCharacter:
						currentState = currentState.Quote (context);
						break;
					default:
						currentState = currentState.AnyChar (ch, context);
						break;
					}
				}
				currentState = currentState.EndOfLine (context);
			}

			List<string[]> allLines = context.GetAllLines();
			return allLines.ToArray();
		}
开发者ID:abstractmachine,项目名称:Fungus-3D-Template,代码行数:38,代码来源:CsvParser.cs

示例5: Parse

		public string[][] Parse(string csvData)
		{
			var context = new ParserContext();

			// Handle both Windows and Mac line endings
			string[] lines = csvData.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);

			ParserState currentState = ParserState.LineStartState;
			foreach (string next in lines)
			{
				foreach (char ch in next)
				{
					switch (ch)
					{
					case CommaCharacter:
						currentState = currentState.Comma(context);
						break;
					case QuoteCharacter:
						currentState = currentState.Quote(context);
						break;
					default:
						currentState = currentState.AnyChar(ch, context);
						break;
					}
				}
				currentState = currentState.EndOfLine(context);
			}
			List<string[]> allLines = context.GetAllLines();
			return allLines.ToArray();
		}
开发者ID:KRUR,项目名称:NotJustASheep,代码行数:30,代码来源:CsvParser.cs


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