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


C# LineInfo.ReadNextLine方法代码示例

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


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

示例1: ExtractQuotedString

		internal static ExtractedInfo ExtractQuotedString(LineInfo line, char quoteChar, bool allowMultiline)
		{
			//			if (line.mReader == null)
			//				throw new BadUsageException("The reader can´t be null");

			if (line.IsEOL())
				throw new BadUsageException("An empty String found and can be parsed like a QuotedString try to use SafeExtractQuotedString");

			if (line.mLine[line.mCurrentPos] != quoteChar)
				throw new BadUsageException("The source string not begins with the quote char: " + quoteChar);

			StringBuilder res = new StringBuilder(32);
			//int lines = 0;

			bool firstFound = false;

			int i = line.mCurrentPos + 1;
			//bool mustContinue = true;

			while (line.mLineStr != null)
			{
				while (i < line.mLine.Length)
				{
					if (line.mLine[i] == quoteChar)
					{
						if (firstFound == true)
						{
							// Is an escaped quoted char
							res.Append(quoteChar);
							firstFound = false;
						}
						else
						{
							firstFound = true;
						}
					}
					else
					{
						if (firstFound)
						{
							// This was the end of the string

							line.mCurrentPos = i;
							return new ExtractedInfo(res.ToString());
//							ExtractedInfo ei = ;
//							return ei;

						}
						else
						{
							res.Append(line.mLine[i]);
						}
					}
					i++;
				}


				if (firstFound)
				{
					line.mCurrentPos = i;
					return new ExtractedInfo(res.ToString());
				}
				else
				{
					if (allowMultiline == false)
						throw new BadUsageException("The current field has an UnClosed quoted string. Complete line: " + res.ToString());

					line.ReadNextLine();
					res.Append(StringHelper.NewLine);
					//lines++;
					i = 0;
				}
			}

			throw new BadUsageException("The current field has an unclosed quoted string. Complete Filed String: " + res.ToString());
		}
开发者ID:pjeconde,项目名称:CedForecast,代码行数:76,代码来源:StringHelper.cs


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