コード例 #1
0
            private IArgumentConverter GetConverter()
            {
                var converterType = _attribute.Converter;

                var isCorrectInterface  = typeof(IArgumentConverter).IsAssignableFrom(converterType);
                var hasEmptyConstructor = converterType.GetConstructor(Type.EmptyTypes) != null;

                if (isCorrectInterface && hasEmptyConstructor)
                {
                    return((IArgumentConverter)Activator.CreateInstance(converterType));
                }

                throw new InvalidOperationException(StringsHelper.InvalidConverter());
            }