public static SchemaObjectBase CreateObject(string schemaTypeString) { ObjectSchemaSettings settings = ObjectSchemaSettings.GetConfig(); ObjectSchemaConfigurationElement schemaElement = settings.Schemas[schemaTypeString]; (schemaElement != null).FalseThrow <NotSupportedException>("不支持的对象类型: {0}", schemaTypeString); SchemaObjectBase result = null; if (schemaElement.GetTypeInfo() == typeof(SCGenericObject)) { result = new SCGenericObject(schemaTypeString); } else { result = (SchemaObjectBase)schemaElement.CreateInstance(schemaTypeString); if (result.SchemaType != schemaTypeString) { throw new SchemaObjectErrorCreationException(string.Format("无法根据指定的SchemaType {0} 创建对应的类型", schemaTypeString)); } } return(result); }
public static DESchemaObjectBase CreateObject(string schemaTypeString) { ObjectSchemaSettings settings = ObjectSchemaSettings.GetConfig(); ObjectSchemaConfigurationElement schemaElement = settings.Schemas[schemaTypeString]; (schemaElement != null).FalseThrow <NotSupportedException>("不支持的对象类型: {0}", schemaTypeString); DESchemaObjectBase result = null; if (schemaElement.GetTypeInfo() == typeof(DEGenericObject)) { result = new DEGenericObject(schemaTypeString); } else { result = (DESchemaObjectBase)schemaElement.CreateInstance(); } return(result); }