本文整理汇总了C#中BufferedTextReader类的典型用法代码示例。如果您正苦于以下问题:C# BufferedTextReader类的具体用法?C# BufferedTextReader怎么用?C# BufferedTextReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BufferedTextReader类属于命名空间,在下文中一共展示了BufferedTextReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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
示例17: Parse
public static double Parse(BufferedTextReader reader)
{
var cur = reader.Read();
if (cur == ',' || cur == ')')
return 0;
return ParseDouble(reader, ref cur, ')');
}
开发者ID:dstimac,项目名称:revenj,代码行数:7,代码来源:DoubleConverter.cs
示例18: DeserializeNullableCollection
public static void DeserializeNullableCollection(BufferedTextReader sr, int nextToken, ICollection<TreePath?> res)
{
if (nextToken == 'n')
{
if (sr.Read() == 'u' && sr.Read() == 'l' && sr.Read() == 'l')
res.Add(null);
else throw new SerializationException("Invalid value found at position " + JsonSerialization.PositionInStream(sr) + " for string value. Expecting '\"' or null");
}
else res.Add(Deserialize(sr, nextToken));
while ((nextToken = JsonSerialization.GetNextToken(sr)) == ',')
{
nextToken = JsonSerialization.GetNextToken(sr);
if (nextToken == 'n')
{
if (sr.Read() == 'u' && sr.Read() == 'l' && sr.Read() == 'l')
res.Add(null);
else throw new SerializationException("Invalid value found at position " + JsonSerialization.PositionInStream(sr) + " for string value. Expecting '\"' or null");
}
else res.Add(Deserialize(sr, nextToken));
}
if (nextToken != ']')
{
if (nextToken == -1) throw new SerializationException("Unexpected end of json in collection.");
else throw new SerializationException("Expecting ']' at position " + JsonSerialization.PositionInStream(sr) + ". Found " + (char)nextToken);
}
}
开发者ID:ngs-doo,项目名称:revenj,代码行数:26,代码来源:TreePathConverter.cs
示例19: Deserialize
public static bool Deserialize(BufferedTextReader sr, int nextToken)
{
if (nextToken == 't')
{
//TODO: isNext !?
if (sr.Read() == 'r' && sr.Read() == 'u' && sr.Read() == 'e')
return true;
}
else if (nextToken == 'f')
{
if (sr.Read() == 'a' && sr.Read() == 'l' && sr.Read() == 's' && sr.Read() == 'e')
return false;
}
else if (nextToken == '"')
{
nextToken = sr.Read();
if (nextToken == 't')
{
if (sr.Read() == 'r' && sr.Read() == 'u' && sr.Read() == 'e' && sr.Read() == '"')
return true;
}
else if (nextToken == 'f')
{
if (sr.Read() == 'a' && sr.Read() == 'l' && sr.Read() == 's' && sr.Read() == 'e' && sr.Read() == '"')
return false;
}
}
throw new SerializationException("Invalid value found at position " + JsonSerialization.PositionInStream(sr) + " for boolean value. Expecting true or false");
}
开发者ID:dstimac,项目名称:revenj,代码行数:29,代码来源:BoolConverter.cs
示例20: 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
注:本文中的BufferedTextReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论