本文整理汇总了C#中Reader.ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# Reader.ReadLine方法的具体用法?C# Reader.ReadLine怎么用?C# Reader.ReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reader
的用法示例。
在下文中一共展示了Reader.ReadLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: For
public static AssetGraph For(string name, string text)
{
var reader = new Reader();
text.ReadLines(reader.ReadLine);
reader.ReadLine(string.Empty); // Depends on a blank line to tell it to "go" in some cases
return reader.Graph;
}
示例2: Parse
public static Packet Parse(string value, string protocol)
{
Packet packet = null;
Reader reader = new Reader(new MemoryAccessor(System.Text.Encoding.UTF8.GetBytes(value)));
string firstLine = reader.ReadLine();
if (firstLine.ToUpper().StartsWith(protocol.ToUpper() + " "))
{
Response response = new Response();
string[] firstLineParts = firstLine.Split(new char[] { ' ' }, 3);
if (firstLineParts.Length < 2) throw new FormatException("First line must have at least 2 parts");
response.Protocol = firstLineParts[0];
response.ResponseCode = Int32.Parse(firstLineParts[1]);
if (firstLineParts.Length > 2) response.ResponseText = firstLineParts[2];
packet = response;
}
else if (firstLine.ToUpper().EndsWith(" " + protocol.ToUpper()))
{
string[] firstLineParts = firstLine.Split(new char[] { ' ' });
Request req = new Request();
req.Method = firstLineParts[0];
req.Path = firstLineParts[1];
req.Protocol = firstLineParts[2];
packet = req;
}
if (packet != null)
{
string line = reader.ReadLine();
while (!reader.EndOfStream && !String.IsNullOrEmpty(line))
{
if (line.Contains(":"))
{
string[] lineParts = line.Split(new char[] { ':' }, 2);
if (lineParts.Length == 2)
{
string headerName = lineParts[0];
string headerValue = lineParts[1];
packet.Headers.Add(headerName.Trim(), headerValue.Trim());
}
}
line = reader.ReadLine();
}
}
return packet;
}