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


C# XmlSchemas.AddReference方法代码示例

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


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

示例1: SchemaImporter

 internal SchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, CodeDomProvider codeProvider, System.Xml.Serialization.ImportContext context)
 {
     if (!schemas.Contains("http://www.w3.org/2001/XMLSchema"))
     {
         schemas.AddReference(XmlSchemas.XsdSchema);
         schemas.SchemaSet.Add(XmlSchemas.XsdSchema);
     }
     if (!schemas.Contains("http://www.w3.org/XML/1998/namespace"))
     {
         schemas.AddReference(XmlSchemas.XmlSchema);
         schemas.SchemaSet.Add(XmlSchemas.XmlSchema);
     }
     this.schemas = schemas;
     this.options = options;
     this.codeProvider = codeProvider;
     this.context = context;
     this.Schemas.SetCache(this.Context.Cache, this.Context.ShareTypes);
     SchemaImporterExtensionsSection section = System.Configuration.PrivilegedConfigurationManager.GetSection(ConfigurationStrings.SchemaImporterExtensionsSectionPath) as SchemaImporterExtensionsSection;
     if (section != null)
     {
         this.extensions = section.SchemaImporterExtensionsInternal;
     }
     else
     {
         this.extensions = new SchemaImporterExtensionCollection();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:SchemaImporter.cs

示例2: SchemaImporter

 internal SchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, ImportContext context)
 {
     if (!schemas.Contains(XmlSchema.Namespace))
     {
         schemas.AddReference(XmlSchemas.XsdSchema);
         schemas.SchemaSet.Add(XmlSchemas.XsdSchema);
     }
     if (!schemas.Contains(XmlReservedNs.NsXml))
     {
         schemas.AddReference(XmlSchemas.XmlSchema);
         schemas.SchemaSet.Add(XmlSchemas.XmlSchema);
     }
     _schemas = schemas;
     _options = options;
     _context = context;
     Schemas.SetCache(Context.Cache, Context.ShareTypes);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:17,代码来源:SchemaImporter.cs

示例3: SchemaImporter

        internal SchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, CodeDomProvider codeProvider, ImportContext context) {
            if (!schemas.Contains(XmlSchema.Namespace)) {
                schemas.AddReference(XmlSchemas.XsdSchema);
                schemas.SchemaSet.Add(XmlSchemas.XsdSchema);
            }
            if (!schemas.Contains(XmlReservedNs.NsXml)) {
                schemas.AddReference(XmlSchemas.XmlSchema);
                schemas.SchemaSet.Add(XmlSchemas.XmlSchema);
            }
            this.schemas = schemas;
            this.options = options;
            this.codeProvider = codeProvider;
            this.context = context;
            Schemas.SetCache(Context.Cache, Context.ShareTypes);

            SchemaImporterExtensionsSection section = PrivilegedConfigurationManager.GetSection(ConfigurationStrings.SchemaImporterExtensionsSectionPath) as SchemaImporterExtensionsSection;
            if (section != null)
                extensions = section.SchemaImporterExtensionsInternal;
            else
                extensions = new SchemaImporterExtensionCollection();
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:21,代码来源:SchemaImporter.cs

示例4: AddSchema

 private static void AddSchema(XmlSchema schema, bool isEncoded, bool isLiteral, XmlSchemas abstractSchemas, XmlSchemas concreteSchemas, Hashtable references)
 {
     if (schema != null)
     {
         if (isEncoded && !abstractSchemas.Contains(schema))
         {
             if (references.Contains(schema))
             {
                 abstractSchemas.AddReference(schema);
             }
             else
             {
                 abstractSchemas.Add(schema);
             }
         }
         if (isLiteral && !concreteSchemas.Contains(schema))
         {
             if (references.Contains(schema))
             {
                 concreteSchemas.AddReference(schema);
             }
             else
             {
                 concreteSchemas.Add(schema);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:ServiceDescriptionImporter.cs

示例5: CollectEncodedAndLiteralSchemas


//.........这里部分代码省略.........
            {
                references[soapEncoding] = soapEncoding;
            }
            foreach (WsdlNS.ServiceDescription description in serviceDescriptions)
            {
                foreach (WsdlNS.Message message in description.Messages)
                {
                    foreach (WsdlNS.MessagePart part in message.Parts)
                    {
                        bool isEncoded;
                        bool isLiteral;
                        FindUse(part, out isEncoded, out isLiteral);
                        if (part.Element != null && !part.Element.IsEmpty)
                        {
                            XmlSchemaElement element = FindSchemaElement(allSchemas, part.Element);
                            if (element != null)
                            {
                                AddSchema(element.Parent as XmlSchema, isEncoded, isLiteral, encodedSchemas, literalSchemas, references);
                                if (element.SchemaTypeName != null && !element.SchemaTypeName.IsEmpty)
                                {
                                    XmlSchemaType type = FindSchemaType(allSchemas, element.SchemaTypeName);
                                    if (type != null)
                                    {
                                        AddSchema(type.Parent as XmlSchema, isEncoded, isLiteral, encodedSchemas, literalSchemas, references);
                                    }
                                }
                            }
                        }
                        if (part.Type != null && !part.Type.IsEmpty)
                        {
                            XmlSchemaType type = FindSchemaType(allSchemas, part.Type);
                            if (type != null)
                            {
                                AddSchema(type.Parent as XmlSchema, isEncoded, isLiteral, encodedSchemas, literalSchemas, references);
                            }
                        }
                    }
                }
            }

            Hashtable imports;
            foreach (XmlSchemas schemas in new XmlSchemas[] { encodedSchemas, literalSchemas })
            {
                // collect all imports
                imports = new Hashtable();
                foreach (XmlSchema schema in schemas)
                {
                    AddImport(schema, imports, allSchemas);
                }
                // make sure we add them to the corresponding schema collections
                foreach (XmlSchema schema in imports.Keys)
                {
                    if (references[schema] == null && !schemas.Contains(schema))
                    {
                        schemas.Add(schema);
                    }
                }
            }

            // If a schema was not referenced by either a literal or an encoded message part,
            // add it to both collections. There's no way to tell which it should be.
            imports = new Hashtable();
            foreach (XmlSchema schema in allSchemas.Schemas())
            {
                if (!encodedSchemas.Contains(schema) && !literalSchemas.Contains(schema))
                {
                    AddImport(schema, imports, allSchemas);
                }
            }

            // make sure we add them to the corresponding schema collections
            foreach (XmlSchema schema in imports.Keys)
            {
                if (references[schema] != null)
                    continue;
                if (!encodedSchemas.Contains(schema))
                {
                    encodedSchemas.Add(schema);
                }
                if (!literalSchemas.Contains(schema))
                {
                    literalSchemas.Add(schema);
                }
            }
            if (encodedSchemas.Count > 0)
            {
                foreach (XmlSchema schema in references.Values)
                {
                    encodedSchemas.AddReference(schema);
                }
            }
            if (literalSchemas.Count > 0)
            {
                foreach (XmlSchema schema in references.Values)
                {
                    literalSchemas.AddReference(schema);
                }
            }
            AddSoapEncodingSchemaIfNeeded(literalSchemas);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:101,代码来源:MessageContractImporter.cs

示例6: AddSchema

 static void AddSchema(XmlSchema schema, bool isEncoded, bool isLiteral, XmlSchemas encodedSchemas, XmlSchemas literalSchemas, Hashtable references)
 {
     if (schema != null)
     {
         if (isEncoded && !encodedSchemas.Contains(schema))
         {
             if (references.Contains(schema))
             {
                 encodedSchemas.AddReference(schema);
             }
             else
             {
                 encodedSchemas.Add(schema);
             }
         }
         if (isLiteral && !literalSchemas.Contains(schema))
         {
             if (references.Contains(schema))
             {
                 literalSchemas.AddReference(schema);
             }
             else
             {
                 literalSchemas.Add(schema);
             }
         }
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:28,代码来源:MessageContractImporter.cs

示例7: Import

        private ServiceDescriptionImportWarnings Import(CodeNamespace codeNamespace, ImportContext importContext, Hashtable exportContext, StringCollection warnings) {
            allSchemas = new XmlSchemas();
            foreach (XmlSchema schema in schemas) {
                allSchemas.Add(schema);
            }
            foreach (ServiceDescription description in serviceDescriptions) {
                foreach (XmlSchema schema in description.Types.Schemas) {
                    allSchemas.Add(schema);
                }
            }
            Hashtable references = new Hashtable();
            if (!allSchemas.Contains(ServiceDescription.Namespace)) {
                allSchemas.AddReference(ServiceDescription.Schema);
                references[ServiceDescription.Schema] = ServiceDescription.Schema;
            }
            if (!allSchemas.Contains(Soap.Encoding)) { 
                allSchemas.AddReference(ServiceDescription.SoapEncodingSchema);
                references[ServiceDescription.SoapEncodingSchema] = ServiceDescription.SoapEncodingSchema;
            }
            allSchemas.Compile(null, false);

            // Segregate the schemas containing abstract types from those 
            // containing regular XML definitions.  This is important because
            // when you import something returning the ur-type (object), then
            // you need to import ALL types/elements within ALL schemas.  We
            // don't want the RPC-based types leaking over into the XML-based
            // element definitions.  This also occurs when you have derivation:
            // we need to search the schemas for derived types: but WHICH schemas
            // should we search.
            foreach (ServiceDescription description in serviceDescriptions) {
                foreach (Message message in description.Messages) {
                    foreach (MessagePart part in message.Parts) {
                        bool isEncoded;
                        bool isLiteral;
                        FindUse(part, out isEncoded, out isLiteral);
                        if (part.Element != null && !part.Element.IsEmpty) {
                            if (isEncoded) throw new InvalidOperationException(Res.GetString(Res.CanTSpecifyElementOnEncodedMessagePartsPart, part.Name, message.Name));
                            XmlSchemaElement element = (XmlSchemaElement)allSchemas.Find(part.Element, typeof(XmlSchemaElement));
                            if (element != null) {
                                AddSchema(element.Parent as XmlSchema, isEncoded, isLiteral, abstractSchemas, concreteSchemas, references);
                                if (element.SchemaTypeName != null && !element.SchemaTypeName.IsEmpty) {
                                    XmlSchemaType type = (XmlSchemaType)allSchemas.Find(element.SchemaTypeName, typeof(XmlSchemaType));
                                    if (type != null) {
                                        AddSchema(type.Parent as XmlSchema, isEncoded, isLiteral, abstractSchemas, concreteSchemas, references);
                                    }
                                }
                            }
                        }
                        if (part.Type != null && !part.Type.IsEmpty) {
                            XmlSchemaType type = (XmlSchemaType)allSchemas.Find(part.Type, typeof(XmlSchemaType));
                            if (type != null) {
                                AddSchema(type.Parent as XmlSchema, isEncoded, isLiteral, abstractSchemas, concreteSchemas, references);
                            }
                        }
                    }
                }
            }

            Hashtable imports;
            foreach (XmlSchemas xmlschemas in new XmlSchemas[] { abstractSchemas, concreteSchemas }) {
                // collect all imports
                imports = new Hashtable();
                foreach (XmlSchema schema in xmlschemas) {
                    AddImport(schema, imports);
                }
                // make sure we add them to the corresponding schema collections
                foreach (XmlSchema schema in imports.Keys) {
                    if (references[schema] == null && !xmlschemas.Contains(schema)) {
                        xmlschemas.Add(schema);
                    }
                }
            }

            // If a schema was not referenced by either a literal or an encoded message part,
            // add it to both collections. There's no way to tell which it should be.
            imports = new Hashtable();
            foreach (XmlSchema schema in allSchemas) {
                if (!abstractSchemas.Contains(schema) && !concreteSchemas.Contains(schema)) {
                    AddImport(schema, imports);
                }
            }

            // make sure we add them to the corresponding schema collections
            foreach (XmlSchema schema in imports.Keys) {
                if (references[schema] != null)
                    continue;
                if (!abstractSchemas.Contains(schema)) {
                    abstractSchemas.Add(schema);
                }
                if (!concreteSchemas.Contains(schema)) {
                    concreteSchemas.Add(schema);
                }
            }
            if (abstractSchemas.Count > 0) {
                foreach (XmlSchema schema in references.Values) {
                    abstractSchemas.AddReference(schema);
                }
                StringCollection schemaWarnings = SchemaCompiler.Compile(abstractSchemas);
                foreach (string warning in schemaWarnings)
                    warnings.Add(warning);
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:ServiceDescriptionImporter.cs


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