本文整理汇总了C#中System.IO.StringReader.ReadNameValuePair方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.ReadNameValuePair方法的具体用法?C# StringReader.ReadNameValuePair怎么用?C# StringReader.ReadNameValuePair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StringReader
的用法示例。
在下文中一共展示了StringReader.ReadNameValuePair方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public static MarkupExtensionInfo Parse(string input)
{
#region Parameter Checks
if (!MarkupExtensionPattern.IsMatch(input))
{
string msg = String.Format("{0} is not a MarkupExtension.", input);
throw new InvalidOperationException(msg);
}
#endregion Parameter Checks
var resultInfo = new MarkupExtensionInfo();
using (var reader = new StringReader(input))
{
var parsingMode = MarkupExtensionParsingModeEnum.START;
try
{
//Debug.Print("Parsing '{0}'", input);
//Debug.Indent();
while (MarkupExtensionParsingModeEnum.END != parsingMode
&& MarkupExtensionParsingModeEnum.UNEXPECTED != parsingMode)
{
//Debug.Print(context.ToString());
//Debug.Indent();
switch (parsingMode)
{
case MarkupExtensionParsingModeEnum.START:
parsingMode = reader.ReadMarkupExtensionStart();
break;
case MarkupExtensionParsingModeEnum.MARKUP_NAME:
parsingMode = reader.ReadMarkupName(resultInfo);
break;
case MarkupExtensionParsingModeEnum.NAME_VALUE_PAIR:
parsingMode = reader.ReadNameValuePair(resultInfo);
break;
}
//Debug.Unindent();
}
}
catch (Exception exp)
{
throw new InvalidDataException(
String.Format("Cannot parse markup extension string:\r\n \"{0}\"", input), exp);
}
}
return resultInfo;
}
示例2: Parse
public static MarkupExtensionInfo Parse(string input)
{
if (!MarkupExtensionPattern.IsMatch(input))
{
throw new InvalidOperationException($"{input} is not a MarkupExtension.");
}
var resultInfo = new MarkupExtensionInfo();
using (var reader = new StringReader(input))
{
var parsingMode = MarkupExtensionParsingModeEnum.Start;
try
{
//Debug.Print("Parsing '{0}'", input);
//Debug.Indent();
while ((MarkupExtensionParsingModeEnum.End != parsingMode)
&& (MarkupExtensionParsingModeEnum.Unexpected != parsingMode))
{
//Debug.Print(context.ToString());
//Debug.Indent();
switch (parsingMode)
{
case MarkupExtensionParsingModeEnum.Start:
parsingMode = reader.ReadMarkupExtensionStart();
break;
case MarkupExtensionParsingModeEnum.MarkupName:
parsingMode = reader.ReadMarkupName(resultInfo);
break;
case MarkupExtensionParsingModeEnum.NameValuePair:
parsingMode = reader.ReadNameValuePair(resultInfo);
break;
}
//Debug.Unindent();
}
}
catch (Exception e)
{
throw new InvalidDataException($"Cannot parse markup extension string:\r\n \"{input}\"", e);
}
}
return resultInfo;
}