當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlSchemaObjectCollection.Add方法代碼示例

本文整理匯總了C#中System.Xml.Schema.XmlSchemaObjectCollection.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlSchemaObjectCollection.Add方法的具體用法?C# XmlSchemaObjectCollection.Add怎麽用?C# XmlSchemaObjectCollection.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.Schema.XmlSchemaObjectCollection的用法示例。


在下文中一共展示了XmlSchemaObjectCollection.Add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CollectAttributeUsesNonOverlap

		// Attributes might be redefined, so there is an existing attribute for the same name, skip it.
		// FIXME: this is nothing more than just a hack.
		// Basically it should use
		// XmlSchemaComplexType.AttributeUses.
		XmlSchemaObjectCollection CollectAttributeUsesNonOverlap (
			XmlSchemaObjectCollection src, ClassMap map)
		{
			XmlSchemaObjectCollection atts = new XmlSchemaObjectCollection ();
			foreach (var a in EnumerateAttributes (src, new List<XmlSchemaAttributeGroup> ()))
				if (map.GetAttribute (a.QualifiedName.Name, a.QualifiedName.Namespace) == null)
					atts.Add (a);
			return atts;
		}
開發者ID:frje,項目名稱:SharpLang,代碼行數:13,代碼來源:XmlSchemaImporter.cs

示例2: GetParticleItems

        internal XmlSchemaObjectCollection GetParticleItems(XmlSchemaParticle pt){
            if (pt is XmlSchemaSequence)
                return ((XmlSchemaSequence)pt).Items;
            if (pt is XmlSchemaAll)
                return ((XmlSchemaAll)pt).Items;
            if (pt is XmlSchemaChoice)
                return ((XmlSchemaChoice)pt).Items;
            if (pt is XmlSchemaAny)
                return null;
            // the code below is a little hack for the SOM behavior        
            if (pt is XmlSchemaElement) {
                XmlSchemaObjectCollection Items = new XmlSchemaObjectCollection();
                Items.Add(pt);
                return Items;
            }
            if (pt is XmlSchemaGroupRef)
                return GetParticleItems( ((XmlSchemaGroupRef)pt).Particle );
            // should never get here.
            return null;

        }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:21,代碼來源:XMLSchema.cs

示例3: AddAttribute

            private XmlSchemaAttribute AddAttribute(string localName, string prefix, string childURI, string attrValue, bool bCreatingNewType, XmlSchema parentSchema, XmlSchemaObjectCollection addLocation, XmlSchemaObjectTable compiledAttributes)
            {
                if (childURI == XmlSchema.Namespace)
                {
                    throw new XmlSchemaInferenceException(Res.SchInf_schema, 0, 0);
                }

                XmlSchemaAttribute xsa = null;
                int AttributeType = -1;
                XmlSchemaAttribute returnedAttribute = null;    //this value will change to attributeReference if childURI!= parentURI
                XmlSchema xs = null;
                bool add = true;

                Debug.Assert(compiledAttributes != null); //AttributeUses is never null
                // First we need to look into the already compiled attributes 
                //   (they come from the schemaset which we got on input)
                // If there are none or we don't find it there, then we must search the list of attributes
                //   where we are going to add a new one (if it doesn't exist). 
                //   This is necessary to avoid adding duplicate attribute declarations.
                ICollection searchCollectionPrimary, searchCollectionSecondary;
                if (compiledAttributes.Count > 0) {
                    searchCollectionPrimary = compiledAttributes.Values;
                    searchCollectionSecondary = addLocation;
                }
                else {
                    searchCollectionPrimary = addLocation;
                    searchCollectionSecondary = null;
                }
                if (childURI == XmlReservedNs.NsXml)
                {
                    XmlSchemaAttribute attributeReference = null;
                    //see if the reference exists
                    attributeReference = FindAttributeRef(searchCollectionPrimary, localName, childURI);
                    if (attributeReference == null && searchCollectionSecondary != null) {
                        attributeReference = FindAttributeRef(searchCollectionSecondary, localName, childURI);
                    }
                    if (attributeReference == null)
                    {
                        attributeReference = new XmlSchemaAttribute();
                        attributeReference.RefName = new XmlQualifiedName(localName, childURI);
                        if (bCreatingNewType && this.Occurrence == InferenceOption.Restricted)
                        {
                            attributeReference.Use = XmlSchemaUse.Required;
                        }
                        else
                        {
                            attributeReference.Use = XmlSchemaUse.Optional;
                        }

                        addLocation.Add(attributeReference);
                    }
                    returnedAttribute = attributeReference;
                }
                else
                {
                    if (childURI.Length == 0)
                    {
                        xs = parentSchema;
                        add = false;
                    }
                    else if (childURI != null && !schemaSet.Contains(childURI))
                    {
                        /*if (parentSchema.AttributeFormDefault = XmlSchemaForm.Unqualified && childURI.Length == 0)
                    {
                        xs = parentSchema;
                        add = false;
                        break;
                    }*/
                        xs = new XmlSchema();
                        xs.AttributeFormDefault = XmlSchemaForm.Unqualified;
                        xs.ElementFormDefault = XmlSchemaForm.Qualified;
                        if (childURI.Length != 0)
                            xs.TargetNamespace = childURI;
                        //schemas.Add(childURI, xs);
                        this.schemaSet.Add(xs);
                        if (prefix.Length != 0 && String.Compare(prefix, "xml", StringComparison.OrdinalIgnoreCase) != 0)
                            NamespaceManager.AddNamespace(prefix, childURI);
                    }
                    else
                    {
                        ArrayList col = this.schemaSet.Schemas(childURI) as ArrayList;
                        if (col != null && col.Count > 0)
                        {
                            xs = col[0] as XmlSchema;
                        }

                    }
                    if (childURI.Length != 0) //
                    {
                        XmlSchemaAttribute attributeReference = null;
                        //see if the reference exists
                        attributeReference = FindAttributeRef(searchCollectionPrimary, localName, childURI);
                        if (attributeReference == null & searchCollectionSecondary != null) {
                            attributeReference = FindAttributeRef(searchCollectionSecondary, localName, childURI);
                        }
                        if (attributeReference == null)
                        {
                            attributeReference = new XmlSchemaAttribute();
                            attributeReference.RefName = new XmlQualifiedName(localName, childURI);
                            if (bCreatingNewType && this.Occurrence == InferenceOption.Restricted)
//.........這裏部分代碼省略.........
開發者ID:krytht,項目名稱:DotNetReferenceSource,代碼行數:101,代碼來源:infer.cs

示例4: ValidateDerivationByRestriction

		internal override bool ValidateDerivationByRestriction (XmlSchemaParticle baseParticle,
			ValidationEventHandler h, XmlSchema schema, bool raiseError)
		{
			if (this == baseParticle) // quick check
				return true;

			XmlSchemaElement el = baseParticle as XmlSchemaElement;
			if (el != null) {
				// Forbidden
				if (raiseError)
					error (h, "Invalid sequence paricle derivation.");
				return false;
			}

			XmlSchemaSequence seq = baseParticle as XmlSchemaSequence;
			if (seq != null) {
				// Recurse
				if (!ValidateOccurenceRangeOK (seq, h, schema, raiseError))
					return false;

				// If it is totally optional, then ignore their contents.
				if (seq.ValidatedMinOccurs == 0 && seq.ValidatedMaxOccurs == 0 &&
					this.ValidatedMinOccurs == 0 && this.ValidatedMaxOccurs == 0)
					return true;
				return ValidateRecurse (seq, h, schema, raiseError);
			} 

			XmlSchemaAll all = baseParticle as XmlSchemaAll;
			if (all != null) {
				// RecurseUnordered
				XmlSchemaObjectCollection already = new XmlSchemaObjectCollection ();
				for (int i = 0; i < this.Items.Count; i++) {
					XmlSchemaElement de = this.Items [i] as XmlSchemaElement;
					if (de == null) {
						if (raiseError)
							error (h, "Invalid sequence particle derivation by restriction from all.");
						return false;
					}
					foreach (XmlSchemaElement e in all.Items) {
						if (e.QualifiedName == de.QualifiedName) {
							if (already.Contains (e)) {
								if (raiseError)
									error (h, "Base element particle is mapped to the derived element particle in a sequence two or more times.");
								return false;
							} else {
								already.Add (e);
								if (!de.ValidateDerivationByRestriction (e, h, schema, raiseError))
									return false;
							}
						}
					}
				}
				foreach (XmlSchemaElement e in all.Items)
					if (!already.Contains (e))
						if (!e.ValidateIsEmptiable ()) {
							if (raiseError)
								error (h, "In base -all- particle, mapping-skipped base element which is not emptiable was found.");
							return false;
						}
				return true;
			}
			XmlSchemaAny any = baseParticle as XmlSchemaAny;
			if (any != null) {
				// NSRecurseCheckCardinality
				return ValidateNSRecurseCheckCardinality (any, h, schema, raiseError);
			}
			XmlSchemaChoice choice = baseParticle as XmlSchemaChoice;
			if (choice != null) {
				// MapAndSum
				// In fact it is not Recurse, but it looks almost common.
				return ValidateSeqRecurseMapSumCommon (choice, h, schema, false, true, raiseError);
			}
			return true;
		}
開發者ID:nobled,項目名稱:mono,代碼行數:74,代碼來源:XmlSchemaSequence.cs

示例5: CollectAttributeUsesNonOverlap

		// Attributes might be redefined, so there is an existing attribute for the same name, skip it.
		// FIXME: this is nothing more than just a hack.
		// Basically it should use
		// XmlSchemaComplexType.AttributeUses.
		XmlSchemaObjectCollection CollectAttributeUsesNonOverlap (
			XmlSchemaObjectCollection src, ClassMap map)
		{
			XmlSchemaObjectCollection atts = new XmlSchemaObjectCollection ();
			foreach (XmlSchemaAttribute a in src)
				if (map.GetAttribute (a.QualifiedName.Name, a.QualifiedName.Namespace) == null)
					atts.Add (a);
			return atts;
		}
開發者ID:nestalk,項目名稱:mono,代碼行數:13,代碼來源:XmlSchemaImporter.cs

示例6: FindMatchingElement

            /// <summary>
            /// Verifies that the current element has its corresponding element in the sequence and order is the same.
            /// If the order is not the same, it changes the particle from Sequence to Sequence with Choice.
            /// If there is more elements of the same kind in the sequence, sets maxOccurs to unbounded
            /// </summary>
            /// <param name="bCreatingNewType">True if this is a new type. This is important for setting minOccurs=0 for elements that did not exist in a particle.</param>
            /// <param name="xtr">text reader positioned to the current element</param>
            /// <param name="ct">complex type with Sequence or Choice Particle</param>
            /// <param name="lastUsedSeqItem">ordinal number in the sequence to indicate current sequence position</param>
            /// <param name="itemsMadeOptional">hashtable of elements with minOccurs changed to 0 in order to satisfy sequence requirements. These elements will be rolled back if Sequence becomes Sequence of Choice.</param>
            /// <param name="bParticleChanged">This indicates to the caller if Sequence was changed to Choice</param>
            internal XmlSchemaElement FindMatchingElement(bool bCreatingNewType, XmlReader xtr,XmlSchemaComplexType ct, ref int lastUsedSeqItem, ref bool bParticleChanged, XmlSchema parentSchema, bool setMaxoccurs)
            {
                if (xtr.NamespaceURI == XmlSchema.Namespace)
                {
                    throw new XmlSchemaInferenceException(Res.SchInf_schema, 0, 0);
                }

                bool bItemNotUsedYet = ((lastUsedSeqItem == -1)? true: false);
                XmlSchemaObjectCollection minOccursCandidates = new XmlSchemaObjectCollection(); //elements that are skipped in the sequence and need minOccurs modified.
                if (ct.Particle.GetType() == typeof (XmlSchemaSequence))
                {   
                    string childURI = xtr.NamespaceURI;
                    if (childURI.Length == 0) 
                    {
                        childURI = null;
                    }
                    XmlSchemaSequence xss = (XmlSchemaSequence) ct.Particle;
                    if (xss.Items.Count < 1 && !bCreatingNewType) 
                    {
                        lastUsedSeqItem = 0;
                        XmlSchemaElement e = AddElement(xtr.LocalName, xtr.Prefix, xtr.NamespaceURI, parentSchema, xss.Items,-1);
                        e.MinOccurs = 0;
                        return e;
                    }
                    if (xss.Items[0].GetType() == typeof (XmlSchemaChoice))
                    {   // <sequence minOccurs="0" maxOccurs="unbounded"><choice><element>...</choice></sequence>
                        XmlSchemaChoice xsch = (XmlSchemaChoice) xss.Items[0];
                        for (int i = 0; i < xsch.Items.Count; ++i)
                        {
                            XmlSchemaElement el = xsch.Items[i] as XmlSchemaElement;
                            if (el == null) 
                            {
                                throw new XmlSchemaInferenceException(Res.SchInf_UnknownParticle, 0, 0);
                            }
                            if ((el.Name == xtr.LocalName) &&( parentSchema.TargetNamespace == childURI))
                            {   // element is in the same namespace
                                InferElement(el, false, parentSchema);
                                SetMinMaxOccurs(el, setMaxoccurs);
                                return el;
                            }
                            else if ((el.RefName.Name == xtr.LocalName) && (el.RefName.Namespace == xtr.NamespaceURI))
                            {
                                XmlSchemaElement referencedElement = FindGlobalElement(childURI, xtr.LocalName, out parentSchema);
                                InferElement(referencedElement, false, parentSchema);
                                SetMinMaxOccurs(el, setMaxoccurs);
                                return referencedElement;
                            }
                        }
                        XmlSchemaElement subElement = AddElement(xtr.LocalName, xtr.Prefix, xtr.NamespaceURI, parentSchema, xsch.Items,-1);
                        return subElement;
                    } 
                    else
                    {   //this should be sequence of elements
                        int iSeqItem = 0;   //iterator through schema sequence items
                        if (lastUsedSeqItem >= 0)
                            iSeqItem = lastUsedSeqItem;
                        XmlSchemaParticle particle = xss.Items[iSeqItem] as XmlSchemaParticle;
                        XmlSchemaElement el = particle as XmlSchemaElement;
                        if (el == null)
                        {
                            throw new XmlSchemaInferenceException(Res.SchInf_UnknownParticle, 0, 0);
                        }
                        if (el.Name == xtr.LocalName && parentSchema.TargetNamespace == childURI)
                        {
                            if (!bItemNotUsedYet)   //read: if item was already used one or more times
                                el.MaxOccurs = decimal.MaxValue;    //set it to unbounded
                            lastUsedSeqItem = iSeqItem;
                            InferElement(el, false, parentSchema);
                            SetMinMaxOccurs(el, false);
                            return el;
                        } 
                        else if (el.RefName.Name == xtr.LocalName && el.RefName.Namespace == xtr.NamespaceURI)
                        {
                            if (!bItemNotUsedYet)   //read: if item was already used one or more times
                                el.MaxOccurs = decimal.MaxValue;    //set it to unbounded
                            lastUsedSeqItem = iSeqItem;
                            XmlSchemaElement referencedElement = FindGlobalElement(childURI, xtr.LocalName, out parentSchema);
                            InferElement(referencedElement, false, parentSchema);
                            SetMinMaxOccurs(el, false);
                            return el;
                        }
                        if (bItemNotUsedYet && el.MinOccurs!=decimal.Zero)
                            minOccursCandidates.Add(el);
                        iSeqItem++;
                        while (iSeqItem < xss.Items.Count)
                        {
                            particle = xss.Items[iSeqItem] as XmlSchemaParticle;
                            el = particle as XmlSchemaElement;
                            if (el == null)
//.........這裏部分代碼省略.........
開發者ID:krytht,項目名稱:DotNetReferenceSource,代碼行數:101,代碼來源:infer.cs

示例7: AddAttribute

 private XmlSchemaAttribute AddAttribute(string localName, string prefix, string childURI, string attrValue, bool bCreatingNewType, XmlSchema parentSchema, XmlSchemaObjectCollection addLocation, XmlSchemaObjectTable compiledAttributes)
 {
     ICollection values;
     ICollection is3;
     if (childURI == "http://www.w3.org/2001/XMLSchema")
     {
         throw new XmlSchemaInferenceException("SchInf_schema", 0, 0);
     }
     XmlSchemaAttribute item = null;
     int iTypeFlags = -1;
     XmlSchemaAttribute attribute2 = null;
     XmlSchema schema = null;
     bool flag = true;
     if (compiledAttributes.Count > 0)
     {
         values = compiledAttributes.Values;
         is3 = addLocation;
     }
     else
     {
         values = addLocation;
         is3 = null;
     }
     if (childURI == "http://www.w3.org/XML/1998/namespace")
     {
         XmlSchemaAttribute attribute3 = null;
         attribute3 = this.FindAttributeRef(values, localName, childURI);
         if ((attribute3 == null) && (is3 != null))
         {
             attribute3 = this.FindAttributeRef(is3, localName, childURI);
         }
         if (attribute3 == null)
         {
             attribute3 = new XmlSchemaAttribute {
                 RefName = new XmlQualifiedName(localName, childURI)
             };
             if (bCreatingNewType && (this.Occurrence == InferenceOption.Restricted))
             {
                 attribute3.Use = XmlSchemaUse.Required;
             }
             else
             {
                 attribute3.Use = XmlSchemaUse.Optional;
             }
             addLocation.Add(attribute3);
         }
         attribute2 = attribute3;
     }
     else
     {
         if (childURI.Length == 0)
         {
             schema = parentSchema;
             flag = false;
         }
         else if ((childURI != null) && !this.schemaSet.Contains(childURI))
         {
             schema = new XmlSchema {
                 AttributeFormDefault = XmlSchemaForm.Unqualified,
                 ElementFormDefault = XmlSchemaForm.Qualified
             };
             if (childURI.Length != 0)
             {
                 schema.TargetNamespace = childURI;
             }
             this.schemaSet.Add(schema);
             if ((prefix.Length != 0) && (string.Compare(prefix, "xml", StringComparison.OrdinalIgnoreCase) != 0))
             {
                 this.NamespaceManager.AddNamespace(prefix, childURI);
             }
         }
         else
         {
             ArrayList list = this.schemaSet.Schemas(childURI) as ArrayList;
             if ((list != null) && (list.Count > 0))
             {
                 schema = list[0] as XmlSchema;
             }
         }
         if (childURI.Length != 0)
         {
             XmlSchemaAttribute attribute4 = null;
             attribute4 = this.FindAttributeRef(values, localName, childURI);
             if ((attribute4 == null) & (is3 != null))
             {
                 attribute4 = this.FindAttributeRef(is3, localName, childURI);
             }
             if (attribute4 == null)
             {
                 attribute4 = new XmlSchemaAttribute {
                     RefName = new XmlQualifiedName(localName, childURI)
                 };
                 if (bCreatingNewType && (this.Occurrence == InferenceOption.Restricted))
                 {
                     attribute4.Use = XmlSchemaUse.Required;
                 }
                 else
                 {
                     attribute4.Use = XmlSchemaUse.Optional;
                 }
//.........這裏部分代碼省略.........
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:101,代碼來源:XmlSchemaInference.cs

示例8: DoCompile

		void DoCompile (ValidationEventHandler handler, Hashtable handledUris, XmlSchemaSet col, XmlResolver resolver)
		{
			SetParent ();
			CompilationId = col.CompilationId;
			schemas = col;
			if (!schemas.Contains (this)) // e.g. xs:import
				schemas.Add (this);

			attributeGroups.Clear ();
			attributes.Clear ();
			elements.Clear ();
			groups.Clear ();
			notations.Clear ();
			schemaTypes.Clear ();

			//1. Union and List are not allowed in block default
			if (BlockDefault != XmlSchemaDerivationMethod.All) {
				if((BlockDefault & XmlSchemaDerivationMethod.List)!=0 )
					error(handler, "list is not allowed in blockDefault attribute");
				if((BlockDefault & XmlSchemaDerivationMethod.Union)!=0 )
					error(handler, "union is not allowed in blockDefault attribute");
			}

			//2. Substitution is not allowed in finaldefault.
			if (FinalDefault != XmlSchemaDerivationMethod.All) {
				if((FinalDefault & XmlSchemaDerivationMethod.Substitution)!=0 )
					error(handler, "substitution is not allowed in finalDefault attribute");
			}

			//3. id must be of type ID
			XmlSchemaUtil.CompileID(Id, this, col.IDCollection, handler);

			//4. targetNamespace should be of type anyURI or absent
			if (TargetNamespace != null) {
				if (TargetNamespace.Length == 0)
					error (handler, "The targetNamespace attribute cannot have have empty string as its value.");

				if(!XmlSchemaUtil.CheckAnyUri (TargetNamespace))
					error(handler, TargetNamespace+" is not a valid value for targetNamespace attribute of schema");
			}

			//5. version should be of type normalizedString
			if (!XmlSchemaUtil.CheckNormalizedString(Version))
				error(handler, Version + "is not a valid value for version attribute of schema");

			// Compile the content of this schema

			compilationItems = new XmlSchemaObjectCollection ();
			for (int i = 0; i < Items.Count; i++) {
				compilationItems.Add (Items [i]);
			}

			// First, we run into inclusion schemas to collect 
			// compilation target items into compiledItems.
			for (int i = 0; i < Includes.Count; i++)
				ProcessExternal (handler, handledUris, resolver, Includes [i] as XmlSchemaExternal, col);

			// Compilation phase.
			// At least each Compile() must give unique (qualified) name for each component.
			// It also checks self-resolvable properties correctness.
			// Post compilation schema information contribution is not done here.
			// It should be done by Validate().
			for (int i = 0; i < compilationItems.Count; i++) {
				XmlSchemaObject obj = compilationItems [i];
				if(obj is XmlSchemaAnnotation) {
					int numerr = ((XmlSchemaAnnotation)obj).Compile (handler, this);
					errorCount += numerr;
				} else if (obj is XmlSchemaAttribute) {
					XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
					int numerr = attr.Compile (handler, this);
					errorCount += numerr;
					if(numerr == 0)
					{
						XmlSchemaUtil.AddToTable (Attributes, attr, attr.QualifiedName, handler);
					}
				} else if (obj is XmlSchemaAttributeGroup) {
					XmlSchemaAttributeGroup attrgrp = (XmlSchemaAttributeGroup) obj;
					int numerr = attrgrp.Compile(handler, this);
					errorCount += numerr;
					if (numerr == 0)
						XmlSchemaUtil.AddToTable (
							AttributeGroups,
							attrgrp,
							attrgrp.QualifiedName,
							handler);
				} else if (obj is XmlSchemaComplexType) {
					XmlSchemaComplexType ctype = (XmlSchemaComplexType) obj;
					int numerr = ctype.Compile (handler, this);
					errorCount += numerr;
					if (numerr == 0)
						XmlSchemaUtil.AddToTable (
							schemaTypes,
							ctype,
							ctype.QualifiedName,
							handler);
				} else if (obj is XmlSchemaSimpleType) {
					XmlSchemaSimpleType stype = (XmlSchemaSimpleType) obj;
					stype.islocal = false; //This simple type is toplevel
					int numerr = stype.Compile (handler, this);
					errorCount += numerr;
//.........這裏部分代碼省略.........
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:101,代碼來源:XmlSchema.cs

示例9: AddElement

 private XmlSchemaElement AddElement(string localName, string prefix, string childURI, XmlSchema parentSchema, XmlSchemaObjectCollection addLocation, int positionWithinCollection)
 {
     if (childURI == "http://www.w3.org/2001/XMLSchema")
     {
         throw new XmlSchemaInferenceException("SchInf_schema", 0, 0);
     }
     XmlSchemaElement item = null;
     XmlSchemaElement element2 = item;
     XmlSchema schema = null;
     bool bCreatingNewType = true;
     if (childURI == string.Empty)
     {
         childURI = null;
     }
     if ((parentSchema != null) && (childURI == parentSchema.TargetNamespace))
     {
         item = new XmlSchemaElement {
             Name = localName
         };
         schema = parentSchema;
         if ((schema.ElementFormDefault != XmlSchemaForm.Qualified) && (addLocation != null))
         {
             item.Form = XmlSchemaForm.Qualified;
         }
     }
     else if (this.schemaSet.Contains(childURI))
     {
         item = this.FindGlobalElement(childURI, localName, out schema);
         if (item == null)
         {
             ArrayList list = this.schemaSet.Schemas(childURI) as ArrayList;
             if ((list != null) && (list.Count > 0))
             {
                 schema = list[0] as XmlSchema;
             }
             item = new XmlSchemaElement {
                 Name = localName
             };
             schema.Items.Add(item);
         }
         else
         {
             bCreatingNewType = false;
         }
     }
     else
     {
         schema = this.CreateXmlSchema(childURI);
         if (prefix.Length != 0)
         {
             this.NamespaceManager.AddNamespace(prefix, childURI);
         }
         item = new XmlSchemaElement {
             Name = localName
         };
         schema.Items.Add(item);
     }
     if (parentSchema == null)
     {
         parentSchema = schema;
         this.rootSchema = parentSchema;
     }
     if (childURI != parentSchema.TargetNamespace)
     {
         bool flag2 = true;
         for (int i = 0; i < parentSchema.Includes.Count; i++)
         {
             XmlSchemaImport import = parentSchema.Includes[i] as XmlSchemaImport;
             if ((import != null) && (import.Namespace == childURI))
             {
                 flag2 = false;
             }
         }
         if (flag2)
         {
             XmlSchemaImport import2 = new XmlSchemaImport {
                 Schema = schema,
                 Namespace = childURI
             };
             parentSchema.Includes.Add(import2);
         }
     }
     element2 = item;
     if (addLocation != null)
     {
         if (childURI == parentSchema.TargetNamespace)
         {
             if (this.Occurrence == InferenceOption.Relaxed)
             {
                 item.MinOccurs = 0M;
             }
             if (positionWithinCollection == -1)
             {
                 positionWithinCollection = addLocation.Add(item);
             }
             else
             {
                 addLocation.Insert(positionWithinCollection, item);
             }
         }
//.........這裏部分代碼省略.........
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:101,代碼來源:XmlSchemaInference.cs

示例10: FindMatchingElement

 internal XmlSchemaElement FindMatchingElement(bool bCreatingNewType, XmlReader xtr, XmlSchemaComplexType ct, ref int lastUsedSeqItem, ref bool bParticleChanged, XmlSchema parentSchema, bool setMaxoccurs)
 {
     int num6;
     if (xtr.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
     {
         throw new XmlSchemaInferenceException("SchInf_schema", 0, 0);
     }
     bool flag = lastUsedSeqItem == -1;
     XmlSchemaObjectCollection objects = new XmlSchemaObjectCollection();
     if (!(ct.Particle.GetType() == typeof(XmlSchemaSequence)))
     {
         throw new XmlSchemaInferenceException("SchInf_noseq", 0, 0);
     }
     string namespaceURI = xtr.NamespaceURI;
     if (namespaceURI.Length == 0)
     {
         namespaceURI = null;
     }
     XmlSchemaSequence sequence = (XmlSchemaSequence) ct.Particle;
     if ((sequence.Items.Count < 1) && !bCreatingNewType)
     {
         lastUsedSeqItem = 0;
         XmlSchemaElement element = this.AddElement(xtr.LocalName, xtr.Prefix, xtr.NamespaceURI, parentSchema, sequence.Items, -1);
         element.MinOccurs = 0M;
         return element;
     }
     if (sequence.Items[0].GetType() == typeof(XmlSchemaChoice))
     {
         XmlSchemaChoice choice = (XmlSchemaChoice) sequence.Items[0];
         for (int i = 0; i < choice.Items.Count; i++)
         {
             XmlSchemaElement element2 = choice.Items[i] as XmlSchemaElement;
             if (element2 == null)
             {
                 throw new XmlSchemaInferenceException("SchInf_UnknownParticle", 0, 0);
             }
             if ((element2.Name == xtr.LocalName) && (parentSchema.TargetNamespace == namespaceURI))
             {
                 this.InferElement(element2, false, parentSchema);
                 this.SetMinMaxOccurs(element2, setMaxoccurs);
                 return element2;
             }
             if ((element2.RefName.Name == xtr.LocalName) && (element2.RefName.Namespace == xtr.NamespaceURI))
             {
                 XmlSchemaElement element3 = this.FindGlobalElement(namespaceURI, xtr.LocalName, out parentSchema);
                 this.InferElement(element3, false, parentSchema);
                 this.SetMinMaxOccurs(element2, setMaxoccurs);
                 return element3;
             }
         }
         return this.AddElement(xtr.LocalName, xtr.Prefix, xtr.NamespaceURI, parentSchema, choice.Items, -1);
     }
     int num2 = 0;
     if (lastUsedSeqItem >= 0)
     {
         num2 = lastUsedSeqItem;
     }
     XmlSchemaParticle particle = sequence.Items[num2] as XmlSchemaParticle;
     XmlSchemaElement xse = particle as XmlSchemaElement;
     if (xse == null)
     {
         throw new XmlSchemaInferenceException("SchInf_UnknownParticle", 0, 0);
     }
     if ((xse.Name == xtr.LocalName) && (parentSchema.TargetNamespace == namespaceURI))
     {
         if (!flag)
         {
             xse.MaxOccurs = 79228162514264337593543950335M;
         }
         lastUsedSeqItem = num2;
         this.InferElement(xse, false, parentSchema);
         this.SetMinMaxOccurs(xse, false);
         return xse;
     }
     if ((xse.RefName.Name == xtr.LocalName) && (xse.RefName.Namespace == xtr.NamespaceURI))
     {
         if (!flag)
         {
             xse.MaxOccurs = 79228162514264337593543950335M;
         }
         lastUsedSeqItem = num2;
         XmlSchemaElement element6 = this.FindGlobalElement(namespaceURI, xtr.LocalName, out parentSchema);
         this.InferElement(element6, false, parentSchema);
         this.SetMinMaxOccurs(xse, false);
         return xse;
     }
     if (flag && (xse.MinOccurs != 0M))
     {
         objects.Add(xse);
     }
     num2++;
     while (num2 < sequence.Items.Count)
     {
         particle = sequence.Items[num2] as XmlSchemaParticle;
         xse = particle as XmlSchemaElement;
         if (xse == null)
         {
             throw new XmlSchemaInferenceException("SchInf_UnknownParticle", 0, 0);
         }
         if ((xse.Name == xtr.LocalName) && (parentSchema.TargetNamespace == namespaceURI))
//.........這裏部分代碼省略.........
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:101,代碼來源:XmlSchemaInference.cs

示例11: ProcessAttributes

 internal void ProcessAttributes(ref XmlSchemaElement xse, XmlSchemaType effectiveSchemaType, bool bCreatingNewType, XmlSchema parentSchema)
 {
     XmlSchemaObjectCollection attributesInInstance = new XmlSchemaObjectCollection();
     XmlSchemaComplexType ct = effectiveSchemaType as XmlSchemaComplexType;
     do
     {
         if (this.xtr.NamespaceURI == "http://www.w3.org/2001/XMLSchema")
         {
             throw new XmlSchemaInferenceException("SchInf_schema", 0, 0);
         }
         if (this.xtr.NamespaceURI == "http://www.w3.org/2000/xmlns/")
         {
             if (this.xtr.Prefix == "xmlns")
             {
                 this.NamespaceManager.AddNamespace(this.xtr.LocalName, this.xtr.Value);
             }
         }
         else if (this.xtr.NamespaceURI == "http://www.w3.org/2001/XMLSchema-instance")
         {
             string localName = this.xtr.LocalName;
             if (localName != "nil")
             {
                 if (((localName != "type") && (localName != "schemaLocation")) && (localName != "noNamespaceSchemaLocation"))
                 {
                     throw new XmlSchemaInferenceException("Sch_NotXsiAttribute", localName);
                 }
             }
             else
             {
                 xse.IsNillable = true;
             }
         }
         else
         {
             if ((ct == null) || (ct == XmlSchemaComplexType.AnyType))
             {
                 ct = new XmlSchemaComplexType();
                 xse.SchemaType = ct;
             }
             XmlSchemaAttribute item = null;
             if (((effectiveSchemaType != null) && (effectiveSchemaType.Datatype != null)) && !xse.SchemaTypeName.IsEmpty)
             {
                 XmlSchemaSimpleContent content = new XmlSchemaSimpleContent();
                 ct.ContentModel = content;
                 XmlSchemaSimpleContentExtension extension = new XmlSchemaSimpleContentExtension();
                 content.Content = extension;
                 extension.BaseTypeName = xse.SchemaTypeName;
                 extension.LineNumber = xse.LineNumber;
                 xse.LineNumber = 0;
                 xse.SchemaTypeName = XmlQualifiedName.Empty;
             }
             if (ct.ContentModel != null)
             {
                 XmlSchemaSimpleContentExtension extension2 = this.CheckSimpleContentExtension(ct);
                 item = this.AddAttribute(this.xtr.LocalName, this.xtr.Prefix, this.xtr.NamespaceURI, this.xtr.Value, bCreatingNewType, parentSchema, extension2.Attributes, ct.AttributeUses);
             }
             else
             {
                 item = this.AddAttribute(this.xtr.LocalName, this.xtr.Prefix, this.xtr.NamespaceURI, this.xtr.Value, bCreatingNewType, parentSchema, ct.Attributes, ct.AttributeUses);
             }
             if (item != null)
             {
                 attributesInInstance.Add(item);
             }
         }
     }
     while (this.xtr.MoveToNextAttribute());
     if (!bCreatingNewType && (ct != null))
     {
         this.MakeExistingAttributesOptional(ct, attributesInInstance);
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:72,代碼來源:XmlSchemaInference.cs

示例12: AddReferenceAttributes

 private void AddReferenceAttributes(XmlSchemaObjectCollection attributes, XmlSchema schema)
 {
     SchemaHelper.AddSchemaImport("http://schemas.microsoft.com/2003/10/Serialization/", schema);
     schema.Namespaces.Add("ser", "http://schemas.microsoft.com/2003/10/Serialization/");
     attributes.Add(IdAttribute);
     attributes.Add(RefAttribute);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:7,代碼來源:SchemaExporter.cs

示例13: AddSubstElementRecursively

		private void AddSubstElementRecursively (XmlSchemaObjectCollection col, XmlSchemaElement el)
		{
			if (el.SubstitutingElements != null)
				for (int i = 0; i < el.SubstitutingElements.Count; i++)
					this.AddSubstElementRecursively (col, el.SubstitutingElements [i] as XmlSchemaElement);
			if (!col.Contains (el))
				col.Add (el);
		}
開發者ID:nobled,項目名稱:mono,代碼行數:8,代碼來源:XmlSchemaElement.cs

示例14: ExportMembersMapSchema

		void ExportMembersMapSchema (XmlSchema schema, ClassMap map, XmlTypeMapping baseMap, XmlSchemaObjectCollection outAttributes, out XmlSchemaSequence particle, out XmlSchemaAnyAttribute anyAttribute)
		{
			particle = null;
			XmlSchemaSequence seq = new XmlSchemaSequence ();

			ICollection members = map.ElementMembers;
			if (members != null && !map.HasSimpleContent)
			{
				foreach (XmlTypeMapMemberElement member in members)
				{
					if (baseMap != null && DefinedInBaseMap (baseMap, member)) continue;

					Type memType = member.GetType();
					if (memType == typeof(XmlTypeMapMemberFlatList))
					{
						XmlSchemaParticle part = GetSchemaArrayElement (schema, member.ElementInfo);
						if (part != null) seq.Items.Add (part);
					}
					else if (memType == typeof(XmlTypeMapMemberAnyElement))
					{
						seq.Items.Add (GetSchemaArrayElement (schema, member.ElementInfo));
					}
					else if (memType == typeof(XmlTypeMapMemberElement))
					{
						GetSchemaElement (schema, (XmlTypeMapElementInfo) member.ElementInfo [0], 
							member.DefaultValue, true, new XmlSchemaObjectContainer (seq));
					}
					else
					{
						GetSchemaElement (schema, (XmlTypeMapElementInfo) member.ElementInfo[0], 
							true, new XmlSchemaObjectContainer (seq));
					}
				}
			}

			if (seq.Items.Count > 0)
				particle = seq;

			// Write attributes

			ICollection attributes = map.AttributeMembers;
			if (attributes != null)
			{
				foreach (XmlTypeMapMemberAttribute attr in attributes) {
					if (baseMap != null && DefinedInBaseMap (baseMap, attr)) continue;
					outAttributes.Add (GetSchemaAttribute (schema, attr, true));
				}
			}

			XmlTypeMapMember anyAttrMember = map.DefaultAnyAttributeMember;
			if (anyAttrMember != null)
				anyAttribute = new XmlSchemaAnyAttribute ();
			else
				anyAttribute = null;
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:55,代碼來源:XmlSchemaExporter.cs

示例15: addCollection

 void addCollection(XmlSchemaObjectCollection coll, XmlSchemaObject obj, TreeNode node, ObjectType imgIdx)
 {
     coll.Add(obj);
     node.Tag = obj;
     node.ImageIndex = (int)imgIdx;
     node.SelectedImageIndex = (int)imgIdx;
     CompileSchema();
 }
開發者ID:billjone,項目名稱:xmlstructureeditor,代碼行數:8,代碼來源:Main.cs


注:本文中的System.Xml.Schema.XmlSchemaObjectCollection.Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。