本文整理汇总了C#中Microsoft.ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.ReadLine方法的具体用法?C# Microsoft.ReadLine怎么用?C# Microsoft.ReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft
的用法示例。
在下文中一共展示了Microsoft.ReadLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoSecondPass
internal void DoSecondPass(StreamReader reader, Microsoft.VisualBasic.FileIO.TextFieldParser parser, IBasicAdjList network)
{
// now, the network had been created based on the headers of each section, the list of
// header fields has been populated for each section, nodes have been created.
// so populate the node data, create the edges, and populate edge data
// 1) read line
// 2) if line is a '*' line
// read line and set state, skip next line
// 3) read items based on state
int index = 0;
string line = null;
string[] fields = null;
try
{
while (!parser.EndOfData)
{
if (parser.PeekChars(1) == "*")
{
line = parser.ReadLine();
State = ReadStarLine(line);
// skip the header line
parser.ReadLine();
// reset the index at each * section
index = 0;
continue;
}
// if here, then it is not a header line or star line
fields = Clean(parser.ReadFields());
switch (State)
{
case VnaFileSection.NodeData:
ReadNodeDataFields(fields, network, index++, NodeDataHeaders);
break;
case VnaFileSection.NodeProperties:
ReadNodePropertyFields(fields, network, index++, NodePropertyHeaders);
break;
case VnaFileSection.EdgeData:
ReadEdgeDataFields(fields, network, EdgeDataHeaders);
break;
case VnaFileSection.EdgeProperties:
ReadEdgePropertyFields(fields, network, index++, EdgePropertyHeaders);
break;
default:
throw new InvalidOperationException(string.Format("{0} is an invalid state", State));
}
}
}
catch (FormatException ex)
{
var sb = new StringBuilder();
sb.AppendFormat("A format error occured while reading the line {0}.{1}", parser.LineNumber, Environment.NewLine);
sb.Append(ex.Message);
ErrorMessages.Add(sb.ToString());
}
catch(NullReferenceException ex)
{
var sb = new StringBuilder();
sb.AppendFormat("A null value occured while reading the line {0}.{1}", parser.LineNumber, Environment.NewLine);
sb.Append(ex.Message);
ErrorMessages.Add(sb.ToString());
}
catch (Exception ex)
{
var sb = new StringBuilder();
sb.AppendFormat("An error occurred while reading the line {0}.{1}", parser.LineNumber, Environment.NewLine);
sb.Append(ex.Message);
ErrorMessages.Add(sb.ToString());
}
}
示例2: DoFirstPass
internal void DoFirstPass(TextReader reader, Microsoft.VisualBasic.FileIO.TextFieldParser parser, out int nodeCount, out int edgeCount)
{
string mssg = null;
nodeCount = 0;
edgeCount = 0;
string line = null;
string[] fields = null;
try
{
while (!parser.EndOfData)
{
if (parser.PeekChars(1) == "*")
{
line = parser.ReadLine();
State = ReadStarLine(line);
// next line is header
fields = Clean(parser.ReadFields());
if (ValidateHeaderFields(fields, State, out mssg))
ReadHeaders(fields, State);
else
{
ErrorMessages.Add(mssg);
break;
}
continue;
}
line = parser.ReadLine();
// if here, then it is not a header line or star line
switch (State)
{
case VnaFileSection.NodeData:
nodeCount++;
break;
case VnaFileSection.EdgeData:
edgeCount++;
break;
}
}
}
catch (NullReferenceException ex)
{
var sb = new StringBuilder();
sb.AppendFormat("A null value occured while reading the line {0}.{1}", parser.LineNumber, Environment.NewLine);
sb.Append(ex.Message);
ErrorMessages.Add(sb.ToString());
}
catch (Exception ex)
{
var sb = new StringBuilder();
sb.AppendFormat("An error occurred while reading the line {0}.{1}", parser.LineNumber, Environment.NewLine);
sb.Append(ex.Message);
ErrorMessages.Add(sb.ToString());
}
}