private void makeCode()
        {

            StringBuilder upperChange = new StringBuilder(built_in_type);
            upperChange[0] = built_in_type.ToUpper()[0];

            this.cName = "XsdType" + upperChange;
            GeneratorSimple gs = new GeneratorSimple(cName);
            code += gs.CsCode;
            code += "\r\n";
        }
Esempio n. 2
0
        private void makeCode()
        {
            StringBuilder upperChange = new StringBuilder(built_in_type);

            upperChange[0] = built_in_type.ToUpper()[0];

            this.cName = "XsdType" + upperChange;
            GeneratorSimple gs = new GeneratorSimple(cName);

            code += gs.CsCode;
            code += "\r\n";
        }
Esempio n. 3
0
        private void Generation(string xsdFileName)
        {
            //try
            //{

            string subfoler       = xsdFileName.Replace(".xsd", "");
            string subBuiltInPath = System.IO.Path.Combine(rootFolder_, subfoler);

            System.IO.Directory.CreateDirectory(subBuiltInPath);

            XmlSchema rootSchema = GetSchemaFromFile(xsdFileName);

            bool noUseFile = false;

            foreach (XmlSchemaObject item in rootSchema.Items)
            {
                var csWriter = new StringWriter();

                string schemaObjectName = "";

                if (item is XmlSchemaElement)
                {
                    XmlSchemaElement xe = item as XmlSchemaElement;
                    schemaObjectName = xe.Name + "NoUseFile";
                    noUseFile        = true;
                }
                else if (item is XmlSchemaComplexType)
                {
                    XmlSchemaComplexType xsct = item as XmlSchemaComplexType;

                    //debug
                    Console.WriteLine(xsct.Name);

                    if (this.viewModelFlag_)
                    {
                        CSharpCodeGen.GeneratorViewModel gen = new GeneratorViewModel(xsct, elementRef, includePath, elementSubstitutionRef, elementGroupRef);

                        gen.makeCode();
                        csWriter.WriteLine(gen.CsCode);
                    }
                    else
                    {
                        CSharpCodeGen.Generator gen = new Generator(xsct, elementRef, includePath, elementSubstitutionRef, elementGroupRef);
                        gen.makeCode();
                        csWriter.WriteLine(gen.CsCode);
                    }

                    schemaObjectName = xsct.Name;
                }
                else if (item is XmlSchemaSimpleType)
                {
                    XmlSchemaSimpleType           xsst = item as XmlSchemaSimpleType;
                    CSharpCodeGen.GeneratorSimple gen  = new GeneratorSimple(xsst);
                    csWriter.WriteLine(gen.CsCode);
                    schemaObjectName = xsst.Name;
                }

                // gen 된 string file 저장함
                if (!noUseFile)
                {
                    if (this.viewModelFlag_)
                    {
                        File.WriteAllText(Path.Combine(subBuiltInPath, schemaObjectName + "ViewModel.cs"), csWriter.GetStringBuilder().ToString());
                    }
                    else
                    {
                        File.WriteAllText(Path.Combine(subBuiltInPath, schemaObjectName + ".cs"), csWriter.GetStringBuilder().ToString());
                    }
                }
            }
            //}
            //catch
            //{
            //    Console.WriteLine("errorOcc -----------------------------------------------------------");
            //    Console.ReadLine();
            //}
        }
        private void Generation(string xsdFileName)
        {
            //try
            //{

                string subfoler = xsdFileName.Replace(".xsd", "");
                string subBuiltInPath = System.IO.Path.Combine(rootFolder_, subfoler);
                System.IO.Directory.CreateDirectory(subBuiltInPath);

                XmlSchema rootSchema = GetSchemaFromFile(xsdFileName);

                bool noUseFile = false;

                foreach (XmlSchemaObject item in rootSchema.Items)
                {
                    var csWriter = new StringWriter();

                    string schemaObjectName = "";

                    if (item is XmlSchemaElement)
                    {

                        XmlSchemaElement xe = item as XmlSchemaElement;
                        schemaObjectName = xe.Name + "NoUseFile";
                        noUseFile = true;
                    }
                    else if (item is XmlSchemaComplexType)
                    {
                        XmlSchemaComplexType xsct = item as XmlSchemaComplexType;

                        //debug
                        Console.WriteLine(xsct.Name);

                        if (this.viewModelFlag_)
                        {
                            CSharpCodeGen.GeneratorViewModel gen = new GeneratorViewModel(xsct, elementRef, includePath, elementSubstitutionRef, elementGroupRef);

                            gen.makeCode();
                            csWriter.WriteLine(gen.CsCode);
                        }
                        else
                        {
                            CSharpCodeGen.Generator gen = new Generator(xsct, elementRef, includePath, elementSubstitutionRef, elementGroupRef);
                            gen.makeCode();
                            csWriter.WriteLine(gen.CsCode);
                        }

                        schemaObjectName = xsct.Name;
                    }
                    else if (item is XmlSchemaSimpleType)
                    {
                        XmlSchemaSimpleType xsst = item as XmlSchemaSimpleType;
                        CSharpCodeGen.GeneratorSimple gen = new GeneratorSimple(xsst);
                        csWriter.WriteLine(gen.CsCode);
                        schemaObjectName = xsst.Name;
                    }

                    // gen 된 string file 저장함
                    if (!noUseFile)
                    {
                        if (this.viewModelFlag_)
                        {
                            File.WriteAllText(Path.Combine(subBuiltInPath, schemaObjectName + "ViewModel.cs"), csWriter.GetStringBuilder().ToString());
                        }
                        else
                        {
                            File.WriteAllText(Path.Combine(subBuiltInPath, schemaObjectName + ".cs"), csWriter.GetStringBuilder().ToString());
                        }
                    }
                }
            //}
            //catch 
            //{
            //    Console.WriteLine("errorOcc -----------------------------------------------------------");
            //    Console.ReadLine();
            //}

        }
        private static void Generation(string xsdFileName)
        {
            string subfoler = xsdFileName.Replace(".xsd", "");
            string subBuiltInPath = System.IO.Path.Combine(rootFolder, subfoler);
            System.IO.Directory.CreateDirectory(subBuiltInPath);

            XmlSchema rootSchema = GetSchemaFromFile(xsdFileName);

            bool noUseFile = false;

            foreach (XmlSchemaObject item in rootSchema.Items)
            {
                var csWriter = new StringWriter();

                string schemaObjectName = "";

                if (item is XmlSchemaElement)
                {
                    XmlSchemaElement xe = item as XmlSchemaElement;
                    schemaObjectName = xe.Name + "NoUseFile";
                    noUseFile = true;
                }
                else if (item is XmlSchemaComplexType)
                {
                    XmlSchemaComplexType xsct = item as XmlSchemaComplexType;
                    CSharpCodeGen.Generator gen = new Generator(xsct, elementRef, includePath, elementSubstitutionRef, elementGroupRef);
                    gen.makeCode();
                    csWriter.WriteLine(gen.CsCode);
                    
                    schemaObjectName = xsct.Name;
                }
                else if (item is XmlSchemaSimpleType)
                {
                    XmlSchemaSimpleType xsst = item as XmlSchemaSimpleType;
                    CSharpCodeGen.GeneratorSimple gen = new GeneratorSimple(xsst);
                    csWriter.WriteLine(gen.CsCode);
                    schemaObjectName = xsst.Name;
                }

                if (!noUseFile)
                {
                    File.WriteAllText(Path.Combine(subBuiltInPath, schemaObjectName + ".cs"), csWriter.GetStringBuilder().ToString());
                }
            }
        }