internal SingleValueParser GetSingleValueParser(Type argumentType) { var descriptor = _appSettings.ArgumentTypeDescriptors.GetDescriptorOrThrow(argumentType); SingleValueParser singleValueParser = new SingleValueParser(descriptor); return(singleValueParser); }
public static IParser CreateInstnace(Type argumentType) { if (argumentType.IsGenericType && argumentType.GetGenericTypeDefinition() == typeof(Nullable <>)) { Type underLyingType = argumentType.GetGenericArguments()[0]; SingleValueParser singleValueParser = new SingleValueParser(underLyingType); return(new NullableValueParser(underLyingType, singleValueParser)); } if (argumentType.IsGenericType && argumentType.GetGenericTypeDefinition() == typeof(List <>)) { Type underLyingType = argumentType.GetGenericArguments()[0]; SingleValueParser singleValueParser = new SingleValueParser(underLyingType); return(new ListParser(underLyingType, singleValueParser)); } if (argumentType.IsValueType || argumentType == typeof(string)) { return(new SingleValueParser(argumentType)); } throw new AppRunnerException($"type of '{argumentType.Name}' is not supported"); }
public ListParser(Type underLyingType, SingleValueParser singleValueParser) { _underLyingType = underLyingType; _singleValueParser = singleValueParser; }
public ListParser(SingleValueParser singleValueParser) { _singleValueParser = singleValueParser; }
public NullableValueParser(Type type, SingleValueParser singleValueParser) { _type = type; _singleValueParser = singleValueParser; }