///<summary>
        ///</summary>
        public static void GenerateSchemas(GeneratorContext context)
        {
            XmlSchema schema = RootSchemaGenerator.GenerateXSD(context);

            BIESchemaGenerator.GenerateXSD(context, CollectABIEs(context), schema);
            BDTSchemaGenerator.GenerateXSD(context, CollectBDTs(context), schema);
            ENUMSchemaGenerator.GenerateXSD(context, schema);
            WriteSchemas(context);
        }
예제 #2
0
        ///<summary>
        ///</summary>
        public static GeneratorContext GenerateSchemas(GeneratorContext context)
        {
            BDTSchemaGenerator.GenerateXSD(context, CollectBDTs(context));
            BIESchemaGenerator.GenerateXSD(context, CollectABIEs(context));
            RootSchemaGenerator.GenerateXSD(context);

            if (context.Allschemas)
            {
                CDTSchemaGenerator.GenerateXSD(context, CollectCDTs(context));
                CCSchemaGenerator.GenerateXSD(context, CollectACCs(context));
            }

            if (!Directory.Exists(context.OutputDirectory))
            {
                Directory.CreateDirectory(context.OutputDirectory);
            }
            foreach (SchemaInfo schemaInfo in context.Schemas)
            {
                var xmlWriterSettings = new XmlWriterSettings
                {
                    Indent   = true,
                    Encoding = Encoding.UTF8,
                };
                using (
                    XmlWriter xmlWriter = XmlWriter.Create(context.OutputDirectory + "\\" + schemaInfo.FileName,
                                                           xmlWriterSettings))
                {
// ReSharper disable AssignNullToNotNullAttribute
                    schemaInfo.Schema.Write(xmlWriter);
// ReSharper restore AssignNullToNotNullAttribute
// ReSharper disable PossibleNullReferenceException
                    xmlWriter.Close();
// ReSharper restore PossibleNullReferenceException
                }
            }

            if (context.Annotate)
            {
                try
                {
                    CopyFolder(AddInSettings.CommonXSDPath, context.OutputDirectory);
                }
                catch (DirectoryNotFoundException)
                {
                    MessageBox.Show("Directory '" + AddInSettings.CommonXSDPath + "' not found!", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (IOException ioe)
                {
                    Console.Out.WriteLine("Exception occured:" + ioe.Message);
                }
            }

            return(context);
        }