public void RegisterRef <T>(Expression <Func <T> > member, string cmdPrototype, string envName, string jsonPath, T @default = null, string description = null, bool hidden = false) where T : class { Ensure.NotNull(member, "member"); var optionName = MemberName(member); var option = new OptionValueContainer <T>(optionName, cmdPrototype, GetEnvVarName(envName), GetJsonPath(jsonPath), @default != null, @default); _optionContainers.Add(optionName, option); if (cmdPrototype.IsNotEmptyString()) { _optionSet.Add(cmdPrototype, description, (T value) => option.ParsingFromCmdLine(value), hidden); } }
public void Register <T>(Expression <Func <T> > member, string cmdPrototype, string envName, string jsonPath, T? @default = null, string description = null, bool hidden = false, bool stopParseIfSet = false) where T : struct { Ensure.NotNull(member, "member"); var optionName = MemberName(member); if (typeof(T) == typeof(bool)) { var option = new OptionFlagContainer(optionName, cmdPrototype, GetEnvVarName(envName), GetJsonPath(jsonPath), (bool?)(object)@default, stopParseIfSet); _optionContainers.Add(optionName, option); if (cmdPrototype.IsNotEmptyString()) { _optionSet.Add(cmdPrototype, description, option.ParsingFromCmdLine, hidden); } } else { var option = new OptionValueContainer <T>(optionName, cmdPrototype, GetEnvVarName(envName), GetJsonPath(jsonPath), @default.HasValue, @default ?? default(T)); _optionContainers.Add(optionName, option); if (cmdPrototype.IsNotEmptyString()) { _optionSet.Add(cmdPrototype, description, (T value) => option.ParsingFromCmdLine(value), hidden); } } }