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


C# BufferedTextReader.BufferToString方法代码示例

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


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

示例1: ParseDouble

		private static double ParseDouble(BufferedTextReader reader, ref int cur, char matchEnd)
		{
			reader.InitBuffer((char)cur);
			reader.FillUntil(',', matchEnd);
			cur = reader.Read();
			//TODO: optimize
			return double.Parse(reader.BufferToString(), NumberStyles.Float, CultureInfo.InvariantCulture);
		}
开发者ID:dstimac,项目名称:revenj,代码行数:8,代码来源:DoubleConverter.cs

示例2: Deserialize

 public static TreePath Deserialize(BufferedTextReader sr, int nextToken)
 {
     if (nextToken != '"') throw new SerializationException("Expecting '\"' at position " + JsonSerialization.PositionInStream(sr) + ". Found " + (char)nextToken);
     sr.InitBuffer();
     nextToken = sr.FillUntil('"');
     sr.Read();
     return TreePath.Create(sr.BufferToString());
 }
开发者ID:ngs-doo,项目名称:revenj,代码行数:8,代码来源:TreePathConverter.cs

示例3: Parse

 public static string Parse(BufferedTextReader reader, int context)
 {
     var cur = reader.Read();
     if (cur == ',' || cur == ')')
         return null;
     if (cur != '"' && cur != '\\')
     {
         reader.InitBuffer((char)cur);
         reader.FillUntil(',', ')');
         reader.Read();
         return reader.BufferToString();
     }
     return ParseEscapedString(reader, context, ref cur, ')');
 }
开发者ID:instant-hrvoje,项目名称:revenj,代码行数:14,代码来源:StringConverter.cs

示例4: ParseCollection

 public static List<string> ParseCollection(BufferedTextReader reader, int context, bool allowNull)
 {
     var cur = reader.Read();
     if (cur == ',' || cur == ')')
         return null;
     var espaced = cur != '{';
     if (espaced)
         reader.Read(context);
     var innerContext = context << 1;
     cur = reader.Peek();
     if (cur == '}')
     {
         if (espaced)
             reader.Read(context + 2);
         else
             reader.Read(2);
         return new List<string>(0);
     }
     var list = new List<string>();
     var emptyCol = allowNull ? null : string.Empty;
     do
     {
         cur = reader.Read();
         if (cur == '"' || cur == '\\')
             list.Add(ParseEscapedString(reader, innerContext, ref cur, '}'));
         else
         {
             reader.InitBuffer((char)cur);
             reader.FillUntil(',', '}');
             cur = reader.Read();
             if (reader.BufferMatches("NULL"))
                 list.Add(emptyCol);
             else
                 list.Add(reader.BufferToString());
         }
     } while (cur == ',');
     if (espaced)
         reader.Read(context + 1);
     else
         reader.Read();
     return list;
 }
开发者ID:instant-hrvoje,项目名称:revenj,代码行数:42,代码来源:StringConverter.cs

示例5: ParseEscapedString

		private static string ParseEscapedString(BufferedTextReader reader, int context, ref int cur, char matchEnd)
		{
			cur = reader.Read(context);
			reader.InitBuffer();
			do
			{
				if (cur == '\\' || cur == '"')
				{
					cur = reader.Read(context);
					if (cur == ',' || cur == matchEnd)
						return reader.BufferToString();
					for (int i = 0; i < context - 1; i++)
						cur = reader.Read();
				}
				reader.AddToBuffer((char)cur);
				reader.FillUntil('\\', '"');
				cur = reader.Read();
			} while (cur != -1);
			throw new FrameworkException("Unable to find end of string");
		}
开发者ID:dstimac,项目名称:revenj,代码行数:20,代码来源:StringConverter.cs

示例6: ParseDictionary

 private static Dictionary<string, string> ParseDictionary(
     BufferedTextReader reader,
     int context,
     int quoteContext,
     ref int cur,
     char matchEnd)
 {
     cur = reader.Read(quoteContext);
     if (cur == ',' || cur == matchEnd)
         return new Dictionary<string, string>(0);
     var dict = new Dictionary<string, string>();
     for (int i = 0; i < context; i++)
         cur = reader.Read();
     reader.InitBuffer();
     do
     {
         do
         {
             if (cur == '\\' || cur == '"')
             {
                 cur = reader.Read(quoteContext);
                 if (cur == '=')
                     break;
                 for (int i = 0; i < quoteContext - 1; i++)
                     cur = reader.Read();
             }
             reader.AddToBuffer((char)cur);
             reader.FillUntil('\\', '"');
             cur = reader.Read();
         } while (cur != -1);
         var name = reader.BufferToString();
         cur = reader.Read(2);
         if (cur == 'N')
         {
             dict.Add(name, null);
             cur = reader.Read(4);
             if (cur == '\\' || cur == '"')
             {
                 reader.Read(context);
                 return dict;
             }
             if (cur == ',' && reader.Peek() != ' ')
                 return dict;
             do { cur = reader.Read(); }
             while (cur == ' ');
         }
         else
         {
             cur = reader.Read(quoteContext);
             do
             {
                 if (cur == '\\' || cur == '"')
                 {
                     cur = reader.Read(quoteContext);
                     if (cur == ',')
                     {
                         dict.Add(name, reader.BufferToString());
                         do { cur = reader.Read(); }
                         while (cur == ' ');
                         cur = reader.Read(quoteContext);
                         break;
                     }
                     for (int i = 0; i < context; i++)
                         cur = reader.Read();
                     if (cur == ',' || cur == -1 || cur == matchEnd)
                     {
                         dict.Add(name, reader.BufferToString());
                         return dict;
                     }
                     for (int i = 0; i < context - 1; i++)
                         cur = reader.Read();
                 }
                 reader.AddToBuffer((char)cur);
                 reader.FillUntil('\\', '"');
                 cur = reader.Read();
             } while (cur != -1);
         }
     } while (cur != -1);
     return dict;
 }
开发者ID:instant-hrvoje,项目名称:revenj,代码行数:80,代码来源:HstoreConverter.cs

示例7: Deserialize

		public static string Deserialize(BufferedTextReader sr, int nextToken)
		{
			if (nextToken != '"') throw new SerializationException("Expecting '\"' at position " + JsonSerialization.PositionInStream(sr) + ". Found " + (char)nextToken);
			sr.InitBuffer();
			nextToken = sr.FillUntil('"', '\\');
			if (nextToken == '"')
			{
				sr.Read();
				return sr.BufferToString();
			}
			var tmp = sr.SmallBuffer;
			do
			{
				nextToken = sr.Read(2);
				switch (nextToken)
				{
					case 'b': sr.AddToBuffer('\b'); break;
					case 't': sr.AddToBuffer('\t'); break;
					case 'r': sr.AddToBuffer('\r'); break;
					case 'n': sr.AddToBuffer('\n'); break;
					case 'f': sr.AddToBuffer('\f'); break;
					case 'u':
						var len = sr.Read(tmp, 0, 4);
						if (len < 4) sr.Read(tmp, len, 4 - len);//the second one must succeed
						sr.AddToBuffer((char)Convert.ToInt32(new string(tmp, 0, 4), 16));//TODO: optimize to no allocation
						break;
					default:
						sr.AddToBuffer((char)nextToken);
						break;
				}
				nextToken = sr.FillUntil('"', '\\');
			} while (nextToken == '\\');
			sr.Read();
			return sr.BufferToString();
		}
开发者ID:dstimac,项目名称:revenj,代码行数:35,代码来源:StringConverter.cs


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