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


C# XmlSchemaSet.AddMaindocSchemas方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            UblXsdSettings ublSettings = new UblXsdSettings
            {
                XsdValidationEvent = SchemaValidationEventHandler,
                UblXsdInputPath = @"..\..\..\UBL-2.1\xsd",  // Content originally from ubl zip download.
                CodeGenOutputPath = @"..\..\..\UblLarsen.Ubl2",
                OptionOptimizeCommonBasicComponents = true, // remove yagni types from schema before code generation. tests wont work when this is set to false
                CSharpDefaultNamespace = "UblLarsen.Ubl2",
                OptionMemberTypeToGenerate = UblXsdSettings.FieldTypesEnum.AutoProperty // or Field, or Property
            };

            XmlSchemaSet schemaSet = new XmlSchemaSet(new NameTable());
            schemaSet.ValidationEventHandler += SchemaValidationEventHandler;
            // Read and add the xsd documents in xsd/maindoc folder
            schemaSet.AddMaindocSchemas(ublSettings);
            schemaSet.Compile();

            if (ublSettings.OptionOptimizeCommonBasicComponents)
            {
                var cbcSchema = schemaSet.Schemas(Constants.CommonBasicComponentsTargetNamespace).Cast<XmlSchema>().Single();
                UblSchemaTypeSimplificationTool.SimplifyCommonBasicComponentsTypes(cbcSchema);
                schemaSet.Reprocess(cbcSchema);
                schemaSet.Compile();
            }

            UblSchemaTypeSimplificationTool.ResolveTypeNameClashesByRenaming(schemaSet);
            schemaSet.Compile();

            var abstractMaindocBaseSchema = UblSchemaInheritanceTools.ModifyMaindocSchemasForInheritance(schemaSet.MaindocSchemas());
            abstractMaindocBaseSchema = schemaSet.Add(abstractMaindocBaseSchema);
            schemaSet.MaindocSchemas().Where(s => s != abstractMaindocBaseSchema).ToList().ForEach(s => schemaSet.Reprocess(s));
            schemaSet.Compile();

            UblCodeGenerator gen = new UblCodeGenerator(ublSettings);
            // namespacelist parameter will drag in all other dependent types. New extensions shold probably be appended here... or...
            var allCodeDecls = gen.CreateCodeTypeDeclarations(schemaSet, 
                new[] {
                    Constants.BaseDocumentTargetNamespace,
                    Constants.SignatureAggregateComponents,
                    Constants.CommonSignatureComponentsTargetNamespace,
                    Constants.Xadesv141TargetNamespace}
                );

            UblDocumentationTool.AddDocumentation(allCodeDecls);

            UblImplicitAssignmentTool.AddImplicitAssignmentOperatorsForXmlTextAttributedDecendants(allCodeDecls);

            XsdTimeTool.IgnoreDateTimeSerializeAsString(allCodeDecls.Where(c => c.Name == "TimeType").Single());

            var mainDocCodeDecls = allCodeDecls.Where(c => c.BaseTypes.Count == 1 && c.BaseTypes[0].BaseType == Constants.abstractBaseSchemaComplexTypeName);
            MainDocsAttributeTool.RenameTopLevelXmlType(mainDocCodeDecls);
            MainDocsAttributeTool.AddXmlRootAttributes(mainDocCodeDecls);

            gen.GenerateAndSaveCodeFilesBySchema(allCodeDecls, new UblNamespaceManager(schemaSet, ublSettings.CSharpDefaultNamespace, ublSettings.OptionOptimizeCommonBasicComponents));

            UblSchemaStatsTool.ShowStats(allCodeDecls);

            Console.WriteLine("DONE");
            Console.ReadLine();
        }
开发者ID:Gammern,项目名称:ubllarsen,代码行数:61,代码来源:Program.cs


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