示例#1
0
            protected virtual ISimpleSchema OnCreate(string schemaLocation)
            {
                var s = new SimpleSchema();

                s.LoadSchema(schemaLocation);
                return(s);
            }
示例#2
0
        /// <summary>
        /// Creates a new instance of <see cref="SimpleSchema"/>
        /// </summary>
        /// <param name="schemaLocation"></param>
        /// <returns></returns>
        public static SimpleSchema CreateSimpleSchema(string schemaLocation)
        {
            SimpleSchema lSchema = new SimpleSchema();

            lSchema.LoadSchema(schemaLocation);

            //lSchema.schemaLocation = schemaLocation;
            //lSchema.initializing = true;

            //// Load complex types
            //foreach (XmlSchemaObject cObject in lSchema.Schema.SchemaTypes.Values)
            //{
            //    XmlSchemaComplexType cComplexType = cObject as XmlSchemaComplexType;

            //    if (cComplexType != null)
            //        lSchema.InitializeComplexType(cComplexType);
            //}

            //// Pick up the full schema
            //foreach (XmlSchemaObject cObject in lSchema.Schema.Items)
            //{
            //    XmlSchemaElement cElement = cObject as XmlSchemaElement;

            //    if (cElement != null)
            //        lSchema.InitializeElement(null, cElement);
            //}

            //lSchema.initializing = false;

            return(lSchema);
        }
示例#3
0
            public SchemaObject(SimpleSchema simpleSchema, XmlSchemaObject xmlObject)
            {
                this.simpleSchema = simpleSchema;
                this.xmlObject    = xmlObject;

                if (xmlObject is XmlSchemaElement)
                {
                    InitializeElementValues(xmlObject as XmlSchemaElement);
                }
                else if (xmlObject is XmlSchemaAttribute)
                {
                    InitializeAttributeValues(xmlObject as XmlSchemaAttribute);
                }
            }
示例#4
0
            private SchemaObject Copy(SchemaObject source, SimpleSchema schema)
            {
                SchemaObject newSchemaObject = new SchemaObject(schema, source.XmlObject)
                {
                    Cardinality = source.Cardinality,
                    Conformance = source.Conformance,
                    DataType    = source.DataType,
                    Name        = source.Name,
                    Type        = source.Type,
                    Mixed       = source.Mixed,
                    Value       = source.Value,
                    XmlObject   = source.XmlObject,
                    FixedValue  = source.FixedValue
                };

                return(newSchemaObject);
            }
示例#5
0
        /// <summary>
        /// Gets a SimpleSchema based on a specific context within the current schema. This is for allowing
        /// a template to be of a different context than just the top-level of the entire schema.
        /// </summary>
        /// <param name="contextType">Indicates if the context is a full XPATH or just a complex type</param>
        /// <param name="context">The context to search for and return as its own schema</param>
        public SimpleSchema GetSchemaFromContext(string context)
        {
            if (string.IsNullOrEmpty(context))
            {
                return(this);
            }

            SchemaObject foundObject = this.complexTypes.SingleOrDefault(y => y.Name.ToLower() == context.ToLower());

            if (foundObject != null)
            {
                SimpleSchema newSimpleSchema = new SimpleSchema();
                newSimpleSchema.namespaces     = this.namespaces;
                newSimpleSchema.schemaLocation = this.schemaLocation;

                newSimpleSchema.Children.Add(foundObject);
                newSimpleSchema.ComplexTypes = this.ComplexTypes;
                newSimpleSchema.isInContext  = true;
                return(newSimpleSchema);
            }

            return(null);
        }
示例#6
0
 public SchemaObject Clone(SimpleSchema schema)
 {
     return(Copy(this, schema));
 }
示例#7
0
        public static SimpleSchema GetSimpleSchema(this ImplementationGuideType igType)
        {
            string schemaLocation = Trifolia.Shared.Helper.GetIGSimplifiedSchemaLocation(igType);

            return(SimpleSchema.CreateSimpleSchema(schemaLocation));
        }