System.ComponentModel.PropertyDescriptor.CreateInstance C# (CSharp) Method

CreateInstance() protected method

Creates an instance of the specified type.

protected CreateInstance ( Type type ) : object
type System.Type
return object
        protected object CreateInstance(Type type)
        {
            Type[] typeArgs = new Type[] { typeof(Type) };
            ConstructorInfo ctor = type.GetTypeInfo().GetConstructor(typeArgs);
            if (ctor != null)
            {
                return TypeDescriptor.CreateInstance(null, type, typeArgs, new object[] { PropertyType });
            }

            return TypeDescriptor.CreateInstance(null, type, null, null);
        }