当前位置: 首页>>代码示例>>C#>>正文


C# SchemaInfo.Add方法代码示例

本文整理汇总了C#中System.Xml.Schema.SchemaInfo.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SchemaInfo.Add方法的具体用法?C# SchemaInfo.Add怎么用?C# SchemaInfo.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Schema.SchemaInfo的用法示例。


在下文中一共展示了SchemaInfo.Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyFromCompiledSet

        internal void CopyFromCompiledSet(XmlSchemaSet otherSet) {
            XmlSchema currentSchema;
            SortedList copyFromList = otherSet.SortedSchemas;
            bool setIsCompiled = schemas.Count == 0 ? true : false; 
            ArrayList existingSchemas = new ArrayList();

            SchemaInfo newCompiledInfo = new SchemaInfo();
            Uri baseUri;
            for(int i=0; i < copyFromList.Count; i++) {
                currentSchema = (XmlSchema)copyFromList.GetByIndex(i);
                baseUri = currentSchema.BaseUri;
                if (schemas.ContainsKey(currentSchema.SchemaId) || (baseUri != null && baseUri.OriginalString.Length != 0 && schemaLocations[baseUri] != null)) {
                    existingSchemas.Add(currentSchema);
                    continue;
                }
                schemas.Add(currentSchema.SchemaId, currentSchema);
                if (baseUri != null && baseUri.OriginalString.Length != 0) {
                    schemaLocations.Add(baseUri, currentSchema);
                }
                string tns = GetTargetNamespace(currentSchema);
                if (targetNamespaces[tns] == null) {
                    targetNamespaces.Add(tns, tns);
                }
            }

            VerifyTables();
            foreach (XmlSchemaElement element in otherSet.GlobalElements.Values) {
                if(!AddToTable(elements, element.QualifiedName, element)) {
                    goto RemoveAll;
                }
            }
            foreach (XmlSchemaAttribute attribute in otherSet.GlobalAttributes.Values) {
                if (!AddToTable(attributes, attribute.QualifiedName, attribute)) {
                    goto RemoveAll;
                }
            }
            foreach (XmlSchemaType schemaType in otherSet.GlobalTypes.Values) {
                if (!AddToTable(schemaTypes, schemaType.QualifiedName, schemaType)) {
                    goto RemoveAll;
                }
            }
            //TODO get otherSet's substitutionGroups
            ProcessNewSubstitutionGroups(otherSet.SubstitutionGroups, false);

            newCompiledInfo.Add(cachedCompiledInfo, eventHandler); //Add all the items from the old to the new compiled object
            newCompiledInfo.Add(otherSet.CompiledInfo,eventHandler); //TODO: Throw error on conflicting types that are not from the same schema / baseUri
            cachedCompiledInfo = newCompiledInfo; //Replace the compiled info in the set after successful compilation
            if (setIsCompiled) {
                isCompiled = true;
                compileAll = false;
            }
            return;
        
            RemoveAll:
                foreach (XmlSchema schemaToRemove in copyFromList.Values) {
                    if (!existingSchemas.Contains(schemaToRemove)) {
                        Remove(schemaToRemove, false);
                    }
                }
                foreach (XmlSchemaElement elementToRemove in otherSet.GlobalElements.Values) {
                    if(!existingSchemas.Contains((XmlSchema)elementToRemove.Parent)) {
                        elements.Remove(elementToRemove.QualifiedName);
                    }
                }
                foreach (XmlSchemaAttribute attributeToRemove in otherSet.GlobalAttributes.Values) {
                    if(!existingSchemas.Contains((XmlSchema)attributeToRemove.Parent)) {
                        attributes.Remove(attributeToRemove.QualifiedName);
                    }
                }
                foreach (XmlSchemaType schemaTypeToRemove in otherSet.GlobalTypes.Values) {
                    if(!existingSchemas.Contains((XmlSchema)schemaTypeToRemove.Parent)) {
                        schemaTypes.Remove(schemaTypeToRemove.QualifiedName);
                    }
                }
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:75,代码来源:xmlschemaset.cs

示例2: CopyFromCompiledSet

 internal void CopyFromCompiledSet(XmlSchemaSet otherSet)
 {
     SortedList sortedSchemas = otherSet.SortedSchemas;
     bool flag = this.schemas.Count == 0;
     ArrayList list2 = new ArrayList();
     SchemaInfo info = new SchemaInfo();
     for (int i = 0; i < sortedSchemas.Count; i++)
     {
         XmlSchema byIndex = (XmlSchema) sortedSchemas.GetByIndex(i);
         Uri baseUri = byIndex.BaseUri;
         if (this.schemas.ContainsKey(byIndex.SchemaId) || (((baseUri != null) && (baseUri.OriginalString.Length != 0)) && (this.schemaLocations[baseUri] != null)))
         {
             list2.Add(byIndex);
         }
         else
         {
             this.schemas.Add(byIndex.SchemaId, byIndex);
             if ((baseUri != null) && (baseUri.OriginalString.Length != 0))
             {
                 this.schemaLocations.Add(baseUri, byIndex);
             }
             string targetNamespace = this.GetTargetNamespace(byIndex);
             if (this.targetNamespaces[targetNamespace] == null)
             {
                 this.targetNamespaces.Add(targetNamespace, targetNamespace);
             }
         }
     }
     this.VerifyTables();
     foreach (XmlSchemaElement element in otherSet.GlobalElements.Values)
     {
         if (!this.AddToTable(this.elements, element.QualifiedName, element))
         {
             goto Label_026E;
         }
     }
     foreach (XmlSchemaAttribute attribute in otherSet.GlobalAttributes.Values)
     {
         if (!this.AddToTable(this.attributes, attribute.QualifiedName, attribute))
         {
             goto Label_026E;
         }
     }
     foreach (XmlSchemaType type in otherSet.GlobalTypes.Values)
     {
         if (!this.AddToTable(this.schemaTypes, type.QualifiedName, type))
         {
             goto Label_026E;
         }
     }
     this.ProcessNewSubstitutionGroups(otherSet.SubstitutionGroups, false);
     info.Add(this.cachedCompiledInfo, this.eventHandler);
     info.Add(otherSet.CompiledInfo, this.eventHandler);
     this.cachedCompiledInfo = info;
     if (flag)
     {
         this.isCompiled = true;
         this.compileAll = false;
     }
     return;
 Label_026E:
     foreach (XmlSchema schema2 in sortedSchemas.Values)
     {
         if (!list2.Contains(schema2))
         {
             this.Remove(schema2, false);
         }
     }
     foreach (XmlSchemaElement element2 in otherSet.GlobalElements.Values)
     {
         if (!list2.Contains((XmlSchema) element2.Parent))
         {
             this.elements.Remove(element2.QualifiedName);
         }
     }
     foreach (XmlSchemaAttribute attribute2 in otherSet.GlobalAttributes.Values)
     {
         if (!list2.Contains((XmlSchema) attribute2.Parent))
         {
             this.attributes.Remove(attribute2.QualifiedName);
         }
     }
     foreach (XmlSchemaType type2 in otherSet.GlobalTypes.Values)
     {
         if (!list2.Contains((XmlSchema) type2.Parent))
         {
             this.schemaTypes.Remove(type2.QualifiedName);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:90,代码来源:XmlSchemaSet.cs

示例3: Compile

        /// <include file='doc\XmlSchemaSet.uex' path='docs/doc[@for="XmlSchemaSet.Compile"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Compile() {
            if (schemas.Count == 0) {
                ClearTables(); //Clear any previously present compiled state left by calling just Remove() on the set
                return;
            }
            if (isCompiled) {
                return;
            }
            lock (InternalSyncObject) {
                
                if (!isCompiled) { //Locking before checking isCompiled to avoid problems with double locking
                    Compiler compiler = new Compiler(nameTable, eventHandler, schemaForSchema, compilationSettings);
                    SchemaInfo newCompiledInfo = new SchemaInfo();
                    int schemaIndex = 0;
                    if (!compileAll) { //if we are not compiling everything again, Move the pre-compiled schemas to the compiler's tables
                        compiler.ImportAllCompiledSchemas(this); 
                    }
                    try { //First thing to do in the try block is to acquire locks since finally will try to release them. 
                        //If we dont accuire the locks first, and an exception occurs in the code before the locking code, then Threading.SynchronizationLockException will be thrown
                        //when attempting to release it in the finally block
                        XmlSchema currentSchema;
                        XmlSchema xmlNSSchema = Preprocessor.GetBuildInSchema();
                        for (schemaIndex = 0; schemaIndex < schemas.Count; schemaIndex++) {
                            currentSchema = (XmlSchema)schemas.GetByIndex(schemaIndex);
                            
                            //Lock schema to be compiled
                            Monitor.Enter(currentSchema);
                            if (!currentSchema.IsPreprocessed) {
                                SendValidationEvent(new XmlSchemaException(Res.Sch_SchemaNotPreprocessed, string.Empty), XmlSeverityType.Error);
                                isCompiled = false;
                                return;
                            }
                            if (currentSchema.IsCompiledBySet) {
                                if (!compileAll) {
                                    continue;
                                }
                                else if ((object)currentSchema == (object)xmlNSSchema) { // prepare for xml namespace schema without cleanup
                                    compiler.Prepare(currentSchema, false);
                                    continue;
                                }
                            }
                            compiler.Prepare(currentSchema, true);
                        }

                        isCompiled = compiler.Execute(this, newCompiledInfo);
                        if (isCompiled) { 
                            compileAll = false;
                            newCompiledInfo.Add(cachedCompiledInfo, eventHandler); //Add all the items from the old to the new compiled object
                            cachedCompiledInfo = newCompiledInfo; //Replace the compiled info in the set after successful compilation
                        }
                    }
                    finally {
                        //Release locks on all schemas
                        XmlSchema currentSchema;
                        if (schemaIndex == schemas.Count) {
                            schemaIndex--;
                        }
                        for (int i = schemaIndex; i >= 0; i--) {
                            currentSchema = (XmlSchema)schemas.GetByIndex(i);
                            if (currentSchema == Preprocessor.GetBuildInSchema()) { //dont re-set compiled flags for xml namespace schema
                                Monitor.Exit(currentSchema);
                                continue;
                            }
                            currentSchema.IsCompiledBySet = isCompiled;
                            Monitor.Exit(currentSchema);
                        }
                    }
                }
            }
            return;
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:75,代码来源:xmlschemaset.cs

示例4: Compile

 public void Compile()
 {
     if (!this.isCompiled)
     {
         if (this.schemas.Count == 0)
         {
             this.ClearTables();
             this.cachedCompiledInfo = new SchemaInfo();
             this.isCompiled = true;
             this.compileAll = false;
         }
         else
         {
             lock (this.InternalSyncObject)
             {
                 if (!this.isCompiled)
                 {
                     Compiler compiler = new Compiler(this.nameTable, this.eventHandler, this.schemaForSchema, this.compilationSettings);
                     SchemaInfo schemaCompiledInfo = new SchemaInfo();
                     int index = 0;
                     if (!this.compileAll)
                     {
                         compiler.ImportAllCompiledSchemas(this);
                     }
                     try
                     {
                         XmlSchema buildInSchema = Preprocessor.GetBuildInSchema();
                         index = 0;
                         while (index < this.schemas.Count)
                         {
                             XmlSchema byIndex = (XmlSchema) this.schemas.GetByIndex(index);
                             Monitor.Enter(byIndex);
                             if (!byIndex.IsPreprocessed)
                             {
                                 this.SendValidationEvent(new XmlSchemaException("Sch_SchemaNotPreprocessed", string.Empty), XmlSeverityType.Error);
                                 this.isCompiled = false;
                                 goto Label_01BA;
                             }
                             if (byIndex.IsCompiledBySet)
                             {
                                 if (!this.compileAll)
                                 {
                                     goto Label_00FD;
                                 }
                                 if (byIndex == buildInSchema)
                                 {
                                     compiler.Prepare(byIndex, false);
                                     goto Label_00FD;
                                 }
                             }
                             compiler.Prepare(byIndex, true);
                         Label_00FD:
                             index++;
                         }
                         this.isCompiled = compiler.Execute(this, schemaCompiledInfo);
                         if (this.isCompiled)
                         {
                             if (!this.compileAll)
                             {
                                 schemaCompiledInfo.Add(this.cachedCompiledInfo, this.eventHandler);
                             }
                             this.compileAll = false;
                             this.cachedCompiledInfo = schemaCompiledInfo;
                         }
                     }
                     finally
                     {
                         if (index == this.schemas.Count)
                         {
                             index--;
                         }
                         for (int i = index; i >= 0; i--)
                         {
                             XmlSchema schema3 = (XmlSchema) this.schemas.GetByIndex(i);
                             if (schema3 == Preprocessor.GetBuildInSchema())
                             {
                                 Monitor.Exit(schema3);
                             }
                             else
                             {
                                 schema3.IsCompiledBySet = this.isCompiled;
                                 Monitor.Exit(schema3);
                             }
                         }
                     }
                 }
             Label_01BA:;
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:91,代码来源:XmlSchemaSet.cs


注:本文中的System.Xml.Schema.SchemaInfo.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。