internal static TSchema GetInstance <TSchema>() where TSchema : ObjectSchema, new() { ObjectSchema.SchemaConstructorDelegate schemaConstructor = () => Activator.CreateInstance <TSchema>(); ObjectSchema instanceImpl = ObjectSchema.GetInstanceImpl(typeof(TSchema), schemaConstructor); return((TSchema)((object)instanceImpl)); }
internal static ObjectSchema GetInstance(Type schemaType) { if (null == schemaType) { throw new ArgumentNullException("schemaType"); } if (!typeof(ObjectSchema).GetTypeInfo().IsAssignableFrom(schemaType.GetTypeInfo())) { throw new ArgumentException(string.Format("Invalid ObjectSchema Input Type: {0}", schemaType), "schemaType"); } if (!ReflectionHelper.HasParameterlessConstructor(schemaType)) { throw new ArgumentException(string.Format("Input type does not have a parameterless constructor: {0}", schemaType), "schemaType"); } ObjectSchema.SchemaConstructorDelegate schemaConstructor = () => (ObjectSchema)Activator.CreateInstance(schemaType); return(ObjectSchema.GetInstanceImpl(schemaType, schemaConstructor)); }