Aqueduct.SitecoreLib.DataAccess.ValueResolvers.ResolverHelper.CreateGenericClassInstance C# (CSharp) Метод

CreateGenericClassInstance() публичный статический Метод

public static CreateGenericClassInstance ( Type genericType, Type argumentType ) : object
genericType System.Type
argumentType System.Type
Результат object
        public static object CreateGenericClassInstance (Type genericType, Type argumentType)
        {
            CheckIsGenericType(genericType, "CreateGenericClassInstance<T>");
            Type type = genericType.MakeGenericType(argumentType);
            return Activator.CreateInstance(type);
        }

Usage Example

        public object ResolveEntityPropertyValue(string rawValue, Type propertyType)
        {
            Type argumentType = ResolverHelper.GetArgumentType(propertyType);
            Type nullableType = typeof(Nullable <>);

            if (!string.IsNullOrEmpty(rawValue))
            {
                object value = GetObjectValue(rawValue, argumentType);
                if (value != null)
                {
                    Type type = nullableType.MakeGenericType(argumentType);
                    return(Activator.CreateInstance(type, value));
                }
            }

            return(ResolverHelper.CreateGenericClassInstance(nullableType, argumentType));
        }