private void Initialize(IValueStoreDefinition value) { Name = value.Name; MetaVar = Name; Store = value; NumArgs = 1; }
private static bool TryConvertFromGeneric(IValueStoreDefinition store, string value, out object obj) { var tempStore = new DummyValueStore { Name = store.Name, Converters = store.Converters, Type = store.Type.GetGenericArguments().First() }; return(TryConvertFrom(tempStore, value, out obj)); }
private void Initialize(IValueStoreDefinition value) { Name = value.Name; MetaVar = Name; Store = value; NumArgs = 1; PromptIfValueMissing = new PromptIfValueMissing() { Enabled = false }; }
private static void AddStaticEnumFormat(StringBuilder builder, IValueStoreDefinition store) { builder.Append("{"); var names = store.Type.GetFields( BindingFlags.Public | BindingFlags.Static) .Where(f => f.IsInitOnly && store.Type.IsAssignableFrom(f.FieldType)) .Select(f => f.Name) .ToArray(); builder.Append(String.Join("|", names)); builder.Append("}"); }
public VerbParserConfig(IParserConfig internalParserConfig, IValueStoreDefinition store, ParserOptions options) : base(options, null) { InternalParserConfig = internalParserConfig; Store = store; LongNameArguments = InternalParserConfig.LongNameArguments; ShortNameArguments = InternalParserConfig.ShortNameArguments; PositionalArguments = InternalParserConfig.PositionalArguments; Verbs = InternalParserConfig.Verbs; PostParseMethods = InternalParserConfig.PostParseMethods; RequiredMutuallyExclusiveArguments = InternalParserConfig.RequiredMutuallyExclusiveArguments; RequiredNamedArguments = InternalParserConfig.RequiredNamedArguments; }
private static void AddEnumFormat(StringBuilder builder, IValueStoreDefinition store) { builder.Append("{"); var names = Enum.GetNames(store.Type); for (var i = 0; i < names.Length; i++) { builder.Append(names[i]); if (i < names.Length - 1) { builder.Append("|"); } } builder.Append("}"); }
public static string[] GetEnumValues(IValueStoreDefinition store) { var typeInfo = store.Type.GetTypeInfo(); if (IsClrEnum(store)) { return Enum.GetNames(store.Type); } else if (IsStaticEnum(store)) { return typeInfo.GetFields( BindingFlags.Public | BindingFlags.Static) .Where(f => f.IsInitOnly && typeInfo.IsAssignableFrom(f.FieldType)) .Select(f => f.Name) .ToArray(); } return new string[0]; }
private static IList CreateGenericList(IValueStoreDefinition store, IEnumerable initial) { var type = store.Type.GetGenericArguments(); if (!type.Any()) { return(null); } var list = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(type)); if (initial != null) { foreach (var elem in initial) { list.Add(elem); } } return(list); }
public static string[] GetEnumValues(IValueStoreDefinition store) { var typeInfo = store.Type.GetTypeInfo(); if (IsClrEnum(store)) { return(Enum.GetNames(store.Type)); } else if (IsStaticEnum(store)) { return(typeInfo.GetFields( BindingFlags.Public | BindingFlags.Static) .Where(f => f.IsInitOnly && typeInfo.IsAssignableFrom(f.FieldType)) .Select(f => f.Name) .ToArray()); } return(new string[0]); }
private static bool TryConvertFrom(IValueStoreDefinition store, string value, out object obj) { var customConverter = store.Converters != null ? store.Converters .FirstOrDefault(c => c.CanConvertFrom(typeof(string))) : null; if (customConverter != null) { obj = customConverter.ConvertFromInvariantString(value); return(true); } var converter = TypeDescriptor.GetConverter(store.Type); if (converter.CanConvertFrom(typeof(string))) { obj = converter.ConvertFromInvariantString(value); return(true); } obj = null; return(false); }
private static bool IsClrEnum(IValueStoreDefinition store) { return(store.Type.GetTypeInfo().IsSubclassOf(typeof(Enum))); }
private static bool IsStaticEnum(IValueStoreDefinition store) { return (store.GetCustomAttribute<StaticEnumerationAttribute>() ?? store.Type.GetTypeInfo().GetCustomAttribute<StaticEnumerationAttribute>()) != null; }
private static bool IsClrEnum(IValueStoreDefinition store) { return store.Type.GetTypeInfo().IsSubclassOf(typeof(Enum)); }
public static bool IsEnum(IValueStoreDefinition store) { return IsClrEnum(store) || IsStaticEnum(store); }
protected NamedBase(CliParserBuilder <TConfig> parser, IValueStoreDefinition store) : base(parser) { Arg = new NamedArgument(store); HasDefaultName = false; }
internal NamedList(CliParser <TConfig> parser, IValueStoreDefinition store) : base(parser, store) { Consumes = new Consumes <TConfig, NamedBase <TConfig, NamedList <TConfig, TArg>, TArg>, TArg>(this); }
public PositionalArgument(IValueStoreDefinition store) : base(store) { }
public PositionalArgument(IValueStoreDefinition store) : base(store) { }
public NamedArgument(IValueStoreDefinition store) : base(store) { }
public NamedArgument(IValueStoreDefinition store) : base(store) { }
/// <summary> /// Create a new Argument. /// </summary> protected BaseArgument(IValueStoreDefinition value) { Initialize(value); }
public static bool IsEnum(IValueStoreDefinition store) { return(IsClrEnum(store) || IsStaticEnum(store)); }
/// <summary> /// Create a new Argument. /// </summary> protected BaseArgument(IValueStoreDefinition value) { Initialize(value); }
internal Positional(CliParserBuilder <TConf> parser, IValueStoreDefinition store) : base(parser, store) { }
private static bool IsStaticEnum(IValueStoreDefinition store) { return((store.GetCustomAttribute <StaticEnumerationAttribute>() ?? store.Type.GetTypeInfo().GetCustomAttribute <StaticEnumerationAttribute>()) != null); }
private void Initialize(IValueStoreDefinition value) { Name = value.Name; MetaVar = Name; Store = value; NumArgs = 1; PromptIfValueMissing = new PromptIfValueMissing() { Enabled = false }; }
protected PositionalBase(CliParser <TConfig> parser, IValueStoreDefinition store) : base(parser) { Arg = Arg = new PositionalArgument(store); }
internal Named(CliParserBuilder <TConfig> parser, IValueStoreDefinition store) : base(parser, store) { }
public PositionalList(CliParserBuilder <TConfig> parser, IValueStoreDefinition store) : base(parser, store) { Consumes = new Consumes <TConfig, PositionalList <TConfig, TArg>, TArg>(this); }