本文整理汇总了C#中IOption.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IOption.Get方法的具体用法?C# IOption.Get怎么用?C# IOption.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOption
的用法示例。
在下文中一共展示了IOption.Get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetExpandoObject
private static ExpandoObject GetExpandoObject(
IOption<Member> member,
IEnumerable<Member> rest)
{
var expandoObject = new ExpandoObject();
var dictionary = (IDictionary<string, object>)expandoObject;
if (member.IsDefined)
{
dictionary.Add(member.Get().Name, member.Get().Value);
foreach (var m in rest)
{
dictionary.Add(m.Name, m.Value);
}
}
return expandoObject;
}
示例2: GetExpandoObject
private static ExpandoObject GetExpandoObject(IOption<Member> firstMember, IEnumerable<Member> otherMembers)
{
var expandoObject = new ExpandoObject();
var d = (IDictionary<string, object>)expandoObject;
if (firstMember.IsDefined)
{
var member = firstMember.Get();
d.Add(member.Name, member.Value);
}
foreach (var member in otherMembers)
{
d.Add(member.Name, member.Value);
}
return expandoObject;
}
示例3: TokenFloat
public TokenFloat(IOption<IEnumerable<char>> minus, string number1, string number2)
{
StringBuilder sb = new StringBuilder();
if (minus.IsDefined && !minus.IsEmpty)
{
foreach (char c in minus.Get())
{
sb.Append(c);
}
}
sb.Append(number1).Append('.').Append(number2);
double f;
if (!Double.TryParse(sb.ToString(), out f))
{
throw new ArgumentException(string.Format("Bad float format: {0}", sb));
}
Value = f;
}
示例4: TokenInteger
internal TokenInteger(IOption<IEnumerable<char>> minus, string number)
{
StringBuilder sb = new StringBuilder();
if (minus.IsDefined && !minus.IsEmpty)
{
foreach (char c in minus.Get())
{
sb.Append(c);
}
}
sb.Append(number);
Int64 v;
if (!Int64.TryParse(sb.ToString(), out v))
{
throw new ArgumentException(string.Format("Bad Int64 format: {0}", sb));
}
Value = v;
}
示例5: GetObjectArray
private static object[] GetObjectArray(IOption<object> firstItem, IEnumerable<object> otherItems)
{
var list = new List<object>();
if (firstItem.IsDefined)
{
list.Add(firstItem.Get());
}
foreach (var item in otherItems)
{
list.Add(item);
}
return list.ToArray();
}
示例6: GetObjectArray
private static object[] GetObjectArray(IOption<object> item, IEnumerable<object> rest)
{
if (!item.IsDefined)
{
return new object[0];
}
return new[] { item.Get() }.Concat(rest).ToArray();
}