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


C# BufferedTextReader类代码示例

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


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

示例1: DeserializeDate

 public static DateTime DeserializeDate(BufferedTextReader sr, int nextToken)
 {
     if (nextToken != '"') throw new SerializationException("Expecting '\"' at position " + JsonSerialization.PositionInStream(sr) + ". Found " + (char)nextToken);
     nextToken = sr.Read();
     int year = 0;
     //TODO: 6!?
     for (int i = 0; i < 6 && (nextToken != '-'); i++, nextToken = sr.Read())
         year = year * 10 + (nextToken - '0');
     nextToken = sr.Read();
     int month = nextToken - 48;
     nextToken = sr.Read();
     if (nextToken != '-')
     {
         month = month * 10 + (nextToken - '0');
         if ((nextToken = sr.Read()) != '-') throw new SerializationException("Expecting '-' at position " + JsonSerialization.PositionInStream(sr) + ". Found " + (char)nextToken);
     }
     nextToken = sr.Read();
     int day = nextToken - 48;
     nextToken = sr.Read();
     if (nextToken != '"' && nextToken != ' ' && nextToken != 'T')
     {
         day = day * 10 + (nextToken - '0');
         nextToken = sr.Read();
     }
     for (int i = 0; i < 24 && nextToken != '"'; i++)
         nextToken = sr.Read();
     if (nextToken != '"') throw new SerializationException("Expecting '\"' at position " + JsonSerialization.PositionInStream(sr) + ". Found " + (char)nextToken);
     return new DateTime(year, month, day);
 }
开发者ID:ngs-doo,项目名称:revenj,代码行数:29,代码来源:DateTimeConverter.cs

示例2: ParseNullable

		public static long? ParseNullable(BufferedTextReader reader)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return null;
			return ParseLong(reader, ref cur);
		}
开发者ID:dstimac,项目名称:revenj,代码行数:7,代码来源:LongConverter.cs

示例3: Parse

		public static Image Parse(BufferedTextReader reader, int context)
		{
			var stream = ByteaConverter.ParseStream(reader, context);
			if (stream == null)
				return null;
			return Image.FromStream(stream);
		}
开发者ID:dstimac,项目名称:revenj,代码行数:7,代码来源:ImageConverter.cs

示例4: ParseCollection

		public static List<long> 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<long>();
			cur = reader.Peek();
			if (cur == '}')
				reader.Read();
			while (cur != -1 && cur != '}')
			{
				cur = reader.Read();
				if (cur == 'N')
				{
					cur = reader.Read(4);
					list.Add(0);
				}
				else
				{
					list.Add(ParseLong(reader, ref cur));
				}
			}
			if (espaced)
				reader.Read(context + 1);
			else
				reader.Read();
			return list;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:31,代码来源:LongConverter.cs

示例5: ProcessRow

 public ResultObjectMapping ProcessRow(IDataReader dr, BufferedTextReader reader)
 {
     var result = new ResultObjectMapping();
     foreach (var sel in Query.Selects)
         result.Add(sel.QuerySource, sel.Instancer(result, reader, dr));
     return result;
 }
开发者ID:instant-hrvoje,项目名称:revenj,代码行数:7,代码来源:SqlCommandData.cs

示例6: Parse

		public static float Parse(BufferedTextReader reader)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return 0;
			return ParseFloat(reader, ref  cur, ')');
		}
开发者ID:dstimac,项目名称:revenj,代码行数:7,代码来源:FloatConverter.cs

示例7: Deserialize

		public static Dictionary<string, string> Deserialize(BufferedTextReader sr, int nextToken)
		{
			if (nextToken != '{') throw new SerializationException("Expecting '{' at position " + JsonSerialization.PositionInStream(sr) + ". Found " + (char)nextToken);
			var res = new Dictionary<string, string>();
			nextToken = JsonSerialization.GetNextToken(sr);
			if (nextToken == '}') return res;
			var key = StringConverter.Deserialize(sr, nextToken);
			nextToken = JsonSerialization.GetNextToken(sr);
			if (nextToken != ':') throw new SerializationException("Expecting ':' at position " + JsonSerialization.PositionInStream(sr) + ". Found " + (char)nextToken);
			nextToken = JsonSerialization.GetNextToken(sr);
			var value = StringConverter.DeserializeNullable(sr, nextToken);
			res.Add(key, value);
			while ((nextToken = JsonSerialization.GetNextToken(sr)) == ',')
			{
				nextToken = JsonSerialization.GetNextToken(sr);
				key = StringConverter.Deserialize(sr, nextToken);
				nextToken = JsonSerialization.GetNextToken(sr);
				if (nextToken != ':') throw new SerializationException("Expecting ':' at position " + JsonSerialization.PositionInStream(sr) + ". Found " + (char)nextToken);
				nextToken = JsonSerialization.GetNextToken(sr);
				value = StringConverter.DeserializeNullable(sr, nextToken);
				res.Add(key, value);
			}
			if (nextToken != '}') throw new SerializationException("Expecting '}' at position " + JsonSerialization.PositionInStream(sr) + ". Found " + (char)nextToken);
			return res;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:25,代码来源:DictionaryConverter.cs

示例8: ProcessRow

		public ResultObjectMapping ProcessRow(ResultObjectMapping parent, BufferedTextReader reader, object row)
		{
			var result = new ResultObjectMapping();
			Selects.ForEach(it => result.Add(it.Key, it.Value(row, reader)));
			result.Add(parent);
			return result;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:7,代码来源:SelectSubqueryData.cs

示例9: DeserializeDecimal

 public static decimal DeserializeDecimal(BufferedTextReader sr, ref int nextToken)
 {
     if (nextToken == '"')
     {
         sr.InitBuffer();
         sr.FillUntil('"');
         nextToken = sr.Read(2);
         try
         {
             return sr.BufferToValue(ConvertToDecimal);
         }
         catch (Exception ex)
         {
             throw new SerializationException("Error parsing decimal at " + JsonSerialization.PositionInStream(sr) + ". " + ex.Message, ex);
         }
     }
     var buf = sr.SmallBuffer;
     buf[0] = (char)nextToken;
     var size = sr.ReadNumber(buf, 1) + 1;
     nextToken = sr.Read();
     try
     {
         return ConvertToDecimal(buf, size, sr);
     }
     catch (Exception ex)
     {
         throw new SerializationException("Error parsing decimal at " + JsonSerialization.PositionInStream(sr) + ". " + ex.Message, ex);
     }
 }
开发者ID:instant-hrvoje,项目名称:revenj,代码行数:29,代码来源:NumberConverter.cs

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

示例11: ParseNullable

		public static int? ParseNullable(BufferedTextReader reader)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return null;
			return ParseInt(reader, ref cur, ')');
		}
开发者ID:dstimac,项目名称:revenj,代码行数:7,代码来源:IntConverter.cs

示例12: Skip

		public static void Skip(BufferedTextReader reader, int context)
		{
			var cur = reader.Read();
			if (cur == ',' || cur == ')')
				return;
			if (cur != '"' && cur != '\\')
			{
				reader.InitBuffer();
				reader.FillUntil(',', ')');
				reader.Read();
			}
			else
			{
				cur = reader.Read(context);
				while (cur != -1)
				{
					if (cur == '\\' || cur == '"')
					{
						cur = reader.Read(context);
						if (cur == ',' || cur == ')')
							return;
						cur = reader.Read(context);
					}
					else cur = reader.Read();
				}
				throw new FrameworkException("Unable to find end of string");
			}
		}
开发者ID:dstimac,项目名称:revenj,代码行数:28,代码来源:StringConverter.cs

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

示例14: Parse

 public static Dictionary<string, string> Parse(BufferedTextReader reader, int context)
 {
     var cur = reader.Read();
     if (cur == ',' || cur == ')')
         return null;
     return ParseDictionary(reader, context, context > 0 ? context << 1 : 1, ref cur, ')');
 }
开发者ID:instant-hrvoje,项目名称:revenj,代码行数:7,代码来源:HstoreConverter.cs

示例15: ParseDecimal

		private static decimal ParseDecimal(BufferedTextReader reader, ref int cur, char matchEnd)
		{
			var neg = cur == '-';
			if (neg)
				cur = reader.Read();
			var buf = reader.SmallBuffer;
			buf[0] = (char)cur;
			var size = reader.ReadUntil(buf, 1, ',', matchEnd) + 1;
			cur = reader.Read();
			if (cur >= '0' && cur <= '9' || cur == '.')
				throw new FrameworkException("Too long decimal number: " + new string(buf, 0, size));
			if (size > 18)
			{
				if (neg)
					return -decimal.Parse(new string(buf, 0, size), Invariant);
				return decimal.Parse(new string(buf, 0, size), Invariant);
			}
			long value = 0;
			int scale = 0;
			char ch;
			for (int i = 0; i < size && i < buf.Length; i++)
			{
				ch = buf[i];
				if (ch == '.')
					scale = size - i - 1;
				else
					value = (value << 3) + (value << 1) + ch - 48;
			}
			return new decimal((int)value, (int)(value >> 32), 0, neg, (byte)scale);
		}
开发者ID:dstimac,项目名称:revenj,代码行数:30,代码来源:DecimalConverter.cs


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