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


C# BufferedTextReader.AddToBuffer方法代码示例

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


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

示例1: 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

示例2: 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

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