本文整理汇总了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);
}
示例2: ParseNullable
public static long? ParseNullable(BufferedTextReader reader)
{
var cur = reader.Read();
if (cur == ',' || cur == ')')
return null;
return ParseLong(reader, ref cur);
}
示例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);
}
示例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;
}
示例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;
}
示例6: Parse
public static float Parse(BufferedTextReader reader)
{
var cur = reader.Read();
if (cur == ',' || cur == ')')
return 0;
return ParseFloat(reader, ref cur, ')');
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例11: ParseNullable
public static int? ParseNullable(BufferedTextReader reader)
{
var cur = reader.Read();
if (cur == ',' || cur == ')')
return null;
return ParseInt(reader, ref cur, ')');
}
示例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");
}
}
示例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;
}
示例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, ')');
}
示例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);
}