本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}