/// <summary> /// Check to see if schema is already loaded into the currently active model /// </summary> /// <returns>True if already loaded</returns> internal bool SchemaLoadedInModel() { var modelSchema = new XmlInstanceECSchema(); var schemas = modelSchema.ReadSchemas(); return(schemas.Any(schema => schema.Equals(SchemaName, StringComparison.InvariantCultureIgnoreCase))); }
//WS: check if a specific schema exists in dgn internal bool SchemaLoadedInModel(string strSchemaName) { var modelSchema = new XmlInstanceECSchema(); //WS: Get loaded scheam //IECSchema oSchema = modelSchema.GetLoadedSchema(strSchemaName); //WS: this got null even the schema is loaded! why?? //Schema = modelSchema.GetLoadedSchema(strSchemaName); var schemas = modelSchema.ReadSchemas(); if (schemas.Any(schema => schema.Equals(strSchemaName, StringComparison.InvariantCultureIgnoreCase))) { Schema = GetSchemaFromConnection(strSchemaName); return(true); } return(false); }
/// <summary> /// Loads the schema into the current active model /// </summary> /// <returns>True on success</returns> internal bool LoadSchema() { if (SchemaLoadedInModel()) { return(true); } if (!File.Exists(SchemaPath)) { return(false); } try { var modelSchema = new XmlInstanceECSchema(); var schema = modelSchema.AddSchema(SchemaPath, SchemaMajorVersion, SchemaMinorVersion); return(schema != null); } catch (Exception ex) { Debug.Print("{0} in {1}\n\t{2}", ex, ex.TargetSite, ex.Message); return(false); } }