本文整理匯總了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;
}