本文整理汇总了C#中StringScanner.ExtractToken方法的典型用法代码示例。如果您正苦于以下问题:C# StringScanner.ExtractToken方法的具体用法?C# StringScanner.ExtractToken怎么用?C# StringScanner.ExtractToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringScanner
的用法示例。
在下文中一共展示了StringScanner.ExtractToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}