本文整理汇总了C#中ParseOptions.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# ParseOptions.HasFlag方法的具体用法?C# ParseOptions.HasFlag怎么用?C# ParseOptions.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseOptions
的用法示例。
在下文中一共展示了ParseOptions.HasFlag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryParse
/// <summary>
/// Tries to parse the dataFields using the delimiter and fields. If true,
/// result will hold an IStringConverter that can convert all valid input
/// in the form of dataFields, only extracting fields.
/// </summary>
/// <param name="dataFields">Input string</param>
/// <param name="delimiter">Seperator</param>
/// <param name="fields">Required (conversion) fields</param>
/// <param name="result">Converter</param>
/// <param name="options">Parseoptions</param>
/// <returns>Parse is possible</returns>
public static Boolean TryParse(String dataFields, Char delimiter, String[] fields, out IStringConverter result,
ParseOptions options = ParseOptions.CleanupQuotes)
{
result = new DelimiterConverter(delimiter);
var splittedDataFields = new Queue<String>(dataFields.Split(delimiter));
var fieldsQueue = new Queue<String>(fields);
while (fieldsQueue.Count > 0 && splittedDataFields.Count > 0)
{
var field = fieldsQueue.Peek();
var data = splittedDataFields.Dequeue().Trim();
if (options.HasFlag(ParseOptions.GlueStrings))
while (data.StartsWith("\"") && !data.EndsWith("\"") && splittedDataFields.Count > 0)
data = data + "," + splittedDataFields.Dequeue().Trim();
if (options.HasFlag(ParseOptions.CleanupQuotes))
data = data.Replace("\"", "").Trim();
(result as DelimiterConverter).PushMask(field == data);
if (field == data)
fieldsQueue.Dequeue();
}
return fieldsQueue.Count == 0;
}