本文整理汇总了C#中StringScanner.ParseXmlAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# StringScanner.ParseXmlAttribute方法的具体用法?C# StringScanner.ParseXmlAttribute怎么用?C# StringScanner.ParseXmlAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringScanner
的用法示例。
在下文中一共展示了StringScanner.ParseXmlAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseSpec
private void ParseSpec()
{
faultCode = String.Empty;
Utils.StringScanner specScanner = new StringScanner(SpecStr);
if (IsValid && !specScanner.MatchToken("<ComPort", false, false))
faultCode = Utils.Fcns.CheckedFormat("invalid element name in '{0}' at idx {1}", specScanner.Str, specScanner.Idx);
if (IsValid && !specScanner.ParseXmlAttribute("port", out portName))
faultCode = Utils.Fcns.CheckedFormat("missing port attribute in '{0}' at idx {1}", specScanner.Str, specScanner.Idx);
if (IsValid && specScanner.MatchToken(">", true, false))
{
Utils.StringScanner copy = specScanner;
if (IsValid && !uartConfig.ParseString(ref specScanner))
faultCode = Utils.Fcns.CheckedFormat("unable to parse expected UartConfig element in '{0}' at idx {1}", copy.Str, copy.Idx);
if (IsValid && !specScanner.MatchToken("</ComPort>", true, false))
faultCode = Utils.Fcns.CheckedFormat("missing element close '</ComPort>' in '{0}' at idx {1}", specScanner.Str, specScanner.Idx);
}
else
{
string uartConfigStr = string.Empty;
if (IsValid && !specScanner.ParseXmlAttribute("uartConfig", out uartConfigStr))
faultCode = Utils.Fcns.CheckedFormat("missing expected config attribute in '{0}' at idx {1}", specScanner.Str, specScanner.Idx);
if (IsValid && !uartConfig.ParseString(uartConfigStr))
faultCode = Utils.Fcns.CheckedFormat("uartConfig attribute could not be parsed from '{0}'", uartConfigStr);
if (IsValid && !specScanner.MatchToken("/>", true, false))
faultCode = Utils.Fcns.CheckedFormat("missing element close '/>' in '{0}' at idx {1}", specScanner.Str, specScanner.Idx);
}
}
示例2: ParseString
public bool ParseString(ref StringScanner scan)
{
bool success = true;
this = new ComPortUartConfig(); // clear
scan.SkipOverWhiteSpace();
if (scan.MatchToken("<UartConfig", false, false))
{
fromXml = true;
bool endFound = false;
// mode, baud, dataBits, stopBits, parity
while (!endFound && success && scan.IsIdxValid)
{
if (scan.MatchToken("/>", false, false))
{
endFound = true;
continue;
}
if (!(scan.ParseXmlAttribute("Baud", out baudRate) && baudRate >= 0.0)
&& !scan.ParseXmlAttribute("DataBits", DataBitsCharTokenValueMap, out dataBits)
&& !scan.ParseXmlAttribute("Mode", PortModeTokenValueMap, out portMode)
&& !scan.ParseXmlAttribute("Parity", ParityTokenValueMap, out parity)
&& !scan.ParseXmlAttribute("StopBits", StopBitsCharTokenValueMap, out stopBits)
)
{
success = false;
}
}
if (!endFound)
success = false;
}
else
{
// parse as dos mode style
string token;
success = scan.ExtractToken(out token) && success;
string [] tokens = token.Split(DosModeDelimiters);
int idx = 0;
string baudStr = (tokens.Length > idx ? tokens[idx++] : string.Empty);
string parityCharStr = (tokens.Length > idx ? tokens[idx++] : string.Empty);
string dataBitsCharStr = (tokens.Length > idx ? tokens[idx++] : string.Empty);
string stopBitsCharStr = (tokens.Length > idx ? tokens[idx++] : string.Empty);
string modeCharStr = (tokens.Length > idx ? tokens[idx++] : string.Empty);
success = (tokens.Length >= 4 && tokens.Length <= 5);
success = Double.TryParse(baudStr, out baudRate) && success;
success = StringScanner.FindTokenValueByName(parityCharStr, ParityCharTokenValueMap, out parity) && success;
success = StringScanner.FindTokenValueByName(dataBitsCharStr, DataBitsCharTokenValueMap, out dataBits) && success;
success = StringScanner.FindTokenValueByName(stopBitsCharStr, StopBitsCharTokenValueMap, out stopBits) && success;
success = StringScanner.FindTokenValueByName(modeCharStr, PortModeCharTokenValueMap, out portMode) && success;
}
scan.SkipOverWhiteSpace();
return success;
}
示例3: UpdateFrom
public void UpdateFrom(LPMSimPartConfigBase config)
{
SelectedMapResultPattern = config.MapResultPattern.ItemsAsArray.SafeAccess(SelectedMapResultPatternIndex, String.Empty);
SelectedMapResultSlotStateList = SelectedMapResultSlotStateList.Parse(SelectedMapResultPattern); // fixes null caused by DataContract deserializer.
SelectedCarrierTypeSpec = config.CarrierTypeSpec.ItemsAsArray.SafeAccess(SelectedCarrierTypeSpecIndex, String.Empty);
StringScanner ss = new StringScanner(SelectedCarrierTypeSpec);
SelectedCarrierType = ss.ExtractToken();
InfoPads infoPads = InfoPads.None;
if (ss.ParseXmlAttribute("InfoPads", out infoPads))
SelectedInfoPads = infoPads;
}