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


C# BufferedTextReader.Peek方法代码示例

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


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

示例1: ParseNullableCollection

		public static List<DateTime?> ParseNullableCollection(BufferedTextReader reader, int context)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return null;
			var escaped = cur == '"' || cur == '\\';
			if (escaped)
				reader.Read(context);
			var list = new List<DateTime?>();
			cur = reader.Peek();
			if (cur == '}')
				reader.Read();
			while (cur != -1 && cur != '}')
			{
				cur = reader.Read();
				if (cur == 'N')
				{
					cur = reader.Read(4);
					list.Add(null);
				}
				else
				{
					list.Add(ParseDate(reader, cur));
					cur = reader.Read();
				}
			}
			if (escaped)
				reader.Read(context + 1);
			else
				reader.Read();
			return list;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:32,代码来源:DateConverter.cs

示例2: ParseCollection

 public static List<Dictionary<string, string>> ParseCollection(BufferedTextReader reader, int context, bool allowNulls)
 {
     var cur = reader.Read();
     if (cur == ',' || cur == ')')
         return null;
     var espaced = cur != '{';
     if (espaced)
         reader.Read(context);
     var innerContext = context << 1;
     var list = new List<Dictionary<string, string>>();
     cur = reader.Peek();
     if (cur == '}')
         reader.Read();
     while (cur != -1 && cur != '}')
     {
         cur = reader.Read();
         if (cur == 'N')
         {
             cur = reader.Read(4);
             list.Add(allowNulls ? null : new Dictionary<string, string>());
         }
         else
         {
             list.Add(ParseDictionary(reader, innerContext, innerContext << 1, ref cur, '}'));
         }
     }
     if (espaced)
         reader.Read(context + 1);
     else
         reader.Read();
     return list;
 }
开发者ID:instant-hrvoje,项目名称:revenj,代码行数:32,代码来源:HstoreConverter.cs

示例3: ParseCollection

		public static List<bool> ParseCollection(BufferedTextReader reader, int context)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return null;
			var espaced = cur != '{';
			if (espaced)
				reader.Read(context);
			var list = new List<bool>();
			cur = reader.Peek();
			if (cur == '}')
				reader.Read();
			while (cur != -1 && cur != '}')
			{
				cur = reader.Read();
				if (cur == 't')
					list.Add(true);
				else if (cur == 'f')
					list.Add(false);
				else
				{
					reader.Read(3);
					list.Add(false);
				}
				cur = reader.Read();
			}
			if (espaced)
				reader.Read(context + 1);
			else
				reader.Read();
			return list;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:32,代码来源:BoolConverter.cs

示例4: ParseNullableCollection

		public static List<decimal?> ParseNullableCollection(BufferedTextReader reader, int context)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return null;
			var espaced = cur != '{';
			if (espaced)
				reader.Read(context);
			cur = reader.Peek();
			if (cur == '}')
			{
				if (espaced)
					reader.Read(context + 2);
				else
					reader.Read(2);
				return new List<decimal?>(0);
			}
			var list = new List<decimal?>();
			do
			{
				cur = reader.Read();
				if (cur == 'N')
				{
					list.Add(null);
					cur = reader.Read(4);
				}
				else list.Add(ParseDecimal(reader, ref cur, '}'));
			} while (cur == ',');
			if (espaced)
				reader.Read(context + 1);
			else
				reader.Read();
			return list;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:34,代码来源:DecimalConverter.cs

示例5: ParseCollection

		public static List<byte[]> ParseCollection(BufferedTextReader reader, int context, bool allowNulls)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return null;
			var escaped = cur != '{';
			if (escaped)
				reader.Read(context);
			var innerContext = context << 1;
			var skipInner = innerContext + (innerContext << 1);
			var list = new List<byte[]>();
			cur = reader.Peek();
			if (cur == '}')
				reader.Read();
			var emptyColl = allowNulls ? null : EmptyBytes;
			while (cur != -1 && cur != '}')
			{
				cur = reader.Read();
				if (cur == 'N')
				{
					list.Add(emptyColl);
					cur = reader.Read(4);
				}
				else
				{
					reader.Read(skipInner);
					var item = new List<byte>(1024);
					cur = reader.Read();
					while (cur != -1 && cur != '"' && cur != '\\')
					{
						item.Add((byte)((CharLookup[cur] << 4) + CharLookup[reader.Read()]));
						cur = reader.Read();
					}
					cur = reader.Read(innerContext);
					list.Add(item.ToArray());
				}
			}
			if (escaped)
				reader.Read(context + 1);
			else
				reader.Read();
			return list;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:43,代码来源:ByteaConverter.cs

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

示例7: ParseCollection

		public static List<double> ParseCollection(BufferedTextReader reader, int context)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return null;
			var espaced = cur != '{';
			if (espaced)
				reader.Read(context);
			var list = new List<double>();
			cur = reader.Peek();
			if (cur == '}')
				reader.Read();
			while (cur != -1 && cur != '}')
			{
				cur = reader.Read();
				if (cur == 'N')
				{
					cur = reader.Read();
					if (cur == 'U')
					{
						cur = reader.Read(3);
						list.Add(0);
					}
					else
					{
						list.Add(double.NaN);
						cur = reader.Read(2);
					}
				}
				else
				{
					list.Add(ParseDouble(reader, ref cur, '}'));
				}
			}
			if (espaced)
				reader.Read(context + 1);
			else
				reader.Read();
			return list;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:40,代码来源:DoubleConverter.cs

示例8: ParseCollection

 public static List<DateTime> ParseCollection(BufferedTextReader reader, int context)
 {
     var cur = reader.Read();
     if (cur == ',' || cur == ')')
         return null;
     var escaped = cur != '{';
     if (escaped)
         reader.Read(context);
     var innerContext = context << 1;
     cur = reader.Peek();
     if (cur == '}')
     {
         if (escaped)
             reader.Read(context + 2);
         else
             reader.Read(2);
         return new List<DateTime>(0);
     }
     var list = new List<DateTime>();
     do
     {
         cur = reader.Read();
         if (cur == 'N')
         {
             cur = reader.Read(4);
             list.Add(DateTime.MinValue);
         }
         else
         {
             list.Add(ParseTimestampUtc(reader, innerContext).ToLocalTime());
             cur = reader.Read();
         }
     } while (cur == ',');
     if (escaped)
         reader.Read(context + 1);
     else
         reader.Read();
     return list;
 }
开发者ID:instant-hrvoje,项目名称:revenj,代码行数:39,代码来源:TimestampConverter.cs

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

示例10: ParseStreamCollection

		public static List<Stream> ParseStreamCollection(BufferedTextReader reader, int context, bool allowNulls)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return null;
			var escaped = cur != '{';
			if (escaped)
				reader.Read(context);
			var innerContext = context << 1;
			var skipInner = innerContext + (innerContext << 1);
			var list = new List<Stream>();
			cur = reader.Peek();
			if (cur == '}')
				reader.Read();
			var emptyCol = allowNulls ? null : new MemoryStream();
			var bytes = reader.ByteBuffer;
			while (cur != -1 && cur != '}')
			{
				cur = reader.Read();
				if (cur == 'N')
				{
					list.Add(emptyCol);
					cur = reader.Read(4);
				}
				else
				{
					cur = reader.Read(skipInner + 1);
					int ind = 0;
					while (ind < bytes.Length && cur != '\\' && cur != '"')
					{
						bytes[ind++] = (byte)((CharLookup[cur] << 4) + CharLookup[reader.Read()]);
						cur = reader.Read();
					}
					Stream stream;
					if (cur == '\\' || cur == '"')
					{
						stream = new MemoryStream();
						stream.Write(bytes, 0, ind);
					}
					else
					{
						stream = ChunkedMemoryStream.Create();
						stream.Write(bytes, 0, ind);
						while (cur != -1 && cur != '\\' && cur != '"')
						{
							stream.WriteByte((byte)((CharLookup[cur] << 4) + CharLookup[reader.Read()]));
							cur = reader.Read();
						}
					}
					cur = reader.Read(innerContext);
					stream.Position = 0;
					list.Add(stream);
				}
			}
			if (escaped)
				reader.Read(context + 1);
			else
				reader.Read();
			return list;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:60,代码来源:ByteaConverter.cs

示例11: ParseNullableCollectionUtc

		public static List<DateTime?> ParseNullableCollectionUtc(BufferedTextReader reader, int context)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return null;
			var escaped = cur != '{';
			if (escaped)
				reader.Read(context);
			int innerContext = context == 0 ? 1 : context << 1;
			cur = reader.Peek();
			if (cur == '}')
			{
				if (escaped)
					reader.Read(context + 2);
				else
					reader.Read(2);
				return new List<DateTime?>(0);
			}
			var list = new List<DateTime?>();
			do
			{
				cur = reader.Read();
				if (cur == 'N')
				{
					cur = reader.Read(4);
					list.Add(null);
				}
				else
				{
					list.Add(ParseTimestampUtc(reader, innerContext));
					cur = reader.Read();
				}
			} while (cur == ',');
			if (escaped)
				reader.Read(context + 1);
			else
				reader.Read();
			return list;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:39,代码来源:TimestampConverter.cs

示例12: ParseStreamCollection

 public static List<Stream> ParseStreamCollection(BufferedTextReader reader, int context, bool allowNull)
 {
     var cur = reader.Read();
     if (cur == ',' || cur == ')')
         return null;
     var espaced = cur != '{';
     if (espaced)
         cur = reader.Read(context);
     var innerContext = context << 1;
     var list = new List<Stream>();
     cur = reader.Peek();
     if (cur == '}')
         reader.Read();
     while (cur != -1 && cur != '}')
     {
         cur = reader.Read();
         var cms = ChunkedMemoryStream.Create();
         var sw = cms.GetWriter();
         if (cur == '"' || cur == '\\')
         {
             cur = reader.Read(innerContext);
             while (cur != -1)
             {
                 if (cur == '\\' || cur == '"')
                 {
                     cur = reader.Read(innerContext);
                     if (cur == ',' || cur == '}')
                         break;
                     for (int i = 0; i < innerContext - 1; i++)
                         cur = reader.Read();
                 }
                 sw.Write((char)cur);
                 cur = reader.Read();
             }
             sw.Flush();
             cms.Position = 0;
             list.Add(cms);
         }
         else
         {
             do
             {
                 sw.Write((char)cur);
                 cur = reader.Read();
             } while (cur != -1 && cur != ',' && cur != '}');
             sw.Flush();
             cms.Position = 0;
             if (cms.Matches(NULL))
             {
                 list.Add(null);
                 cms.Dispose();
             }
             else
                 list.Add(cms);
         }
     }
     if (espaced)
         reader.Read(context + 1);
     else
         reader.Read();
     return list;
 }
开发者ID:instant-hrvoje,项目名称:revenj,代码行数:62,代码来源:StringConverter.cs

示例13: ParseCollection

		public static List<Guid> ParseCollection(BufferedTextReader reader, int context)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return null;
			var espaced = cur != '{';
			if (espaced)
				reader.Read(context);
			cur = reader.Peek();
			if (cur == '}')
			{
				if (espaced)
					reader.Read(context + 2);
				else
					reader.Read(2);
				return new List<Guid>(0);
			}
			var list = new List<Guid>();
			do
			{
				cur = reader.Read();
				if (cur == 'N')
				{
					cur = reader.Read(4);
					list.Add(Guid.Empty);
				}
				else
				{
					list.Add(ParseCollectionGuid(reader, cur));
					cur = reader.Read();
				}
			} while (cur == ',');
			if (espaced)
				reader.Read(context + 1);
			else
				reader.Read();
			return list;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:38,代码来源:GuidConverter.cs


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