Пример #1
0
        internal SingleValueParser GetSingleValueParser(Type argumentType)
        {
            var descriptor = _appSettings.ArgumentTypeDescriptors.GetDescriptorOrThrow(argumentType);
            SingleValueParser singleValueParser = new SingleValueParser(descriptor);

            return(singleValueParser);
        }
Пример #2
0
        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");
        }
Пример #3
0
 public ListParser(Type underLyingType, SingleValueParser singleValueParser)
 {
     _underLyingType    = underLyingType;
     _singleValueParser = singleValueParser;
 }
Пример #4
0
 public ListParser(SingleValueParser singleValueParser)
 {
     _singleValueParser = singleValueParser;
 }
Пример #5
0
 public NullableValueParser(Type type, SingleValueParser singleValueParser)
 {
     _type = type;
     _singleValueParser = singleValueParser;
 }