Ejemplo n.º 1
0
        string GetEnumValue_CodeGenerationOptions(System.Xml.Serialization.CodeGenerationOptions val)
        {
            switch (val)
            {
            case System.Xml.Serialization.CodeGenerationOptions.GenerateProperties:
                return("properties");

            case System.Xml.Serialization.CodeGenerationOptions.GenerateNewAsync:
                return("newAsync");

            case System.Xml.Serialization.CodeGenerationOptions.GenerateOldAsync:
                return("oldAsync");

            case System.Xml.Serialization.CodeGenerationOptions.GenerateOrder:
                return("order");

            case System.Xml.Serialization.CodeGenerationOptions.EnableDataBinding:
                return("enableDataBinding");

            default:
                if (val.ToString() == "0")
                {
                    return(string.Empty);
                }
                return(FromEnum((long)val, _xmlNamesCodeGenerationOptions, _valuesCodeGenerationOptions, typeof(System.Xml.Serialization.CodeGenerationOptions).FullName));
            }
        }
Ejemplo n.º 2
0
        void WriteObject_CodeGenerationOptions(System.Xml.Serialization.CodeGenerationOptions ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
        {
            System.Type type = ob.GetType();
            if (type == typeof(System.Xml.Serialization.CodeGenerationOptions))
            {
            }
            else
            {
                throw CreateUnknownTypeException(ob);
            }

            if (writeWrappingElem)
            {
                WriteStartElement(element, namesp, ob);
            }

            if (needType)
            {
                WriteXsiType("CodeGenerationOptions", "http://microsoft.com/webReference/");
            }

            Writer.WriteString(GetEnumValue_CodeGenerationOptions(ob));
            if (writeWrappingElem)
            {
                WriteEndElement(ob);
            }
        }
        string Write1_CodeGenerationOptions(System.Xml.Serialization.CodeGenerationOptions v)
        {
            string s = null;

            switch (v)
            {
            case System.Xml.Serialization.CodeGenerationOptions.@GenerateProperties: s = @"properties"; break;

            case System.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync: s = @"newAsync"; break;

            case System.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync: s = @"oldAsync"; break;

            case System.Xml.Serialization.CodeGenerationOptions.@GenerateOrder: s = @"order"; break;

            case System.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding: s = @"enableDataBinding"; break;

            default: s = FromEnum(((System.Int64)v), new string[] { @"properties",
                                                                    @"newAsync",
                                                                    @"oldAsync",
                                                                    @"order",
                                                                    @"enableDataBinding" }, new System.Int64[] { (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateProperties,
                                                                                                                 (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateNewAsync,
                                                                                                                 (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateOldAsync,
                                                                                                                 (long)System.Xml.Serialization.CodeGenerationOptions.@GenerateOrder,
                                                                                                                 (long)System.Xml.Serialization.CodeGenerationOptions.@EnableDataBinding }, @"System.Xml.Serialization.CodeGenerationOptions"); break;
            }
            return(s);
        }
Ejemplo n.º 4
0
 public System.Xml.Serialization.CodeGenerationOptions ReadObject_CodeGenerationOptions(bool isNullable, bool checkType)
 {
     Reader.ReadStartElement();
     System.Xml.Serialization.CodeGenerationOptions res = GetEnumValue_CodeGenerationOptions(Reader.ReadString());
     if (Reader.NodeType != XmlNodeType.None)
     {
         Reader.ReadEndElement();
     }
     return(res);
 }
 public ServiceDescriptionImporter()
 {
     this.serviceDescriptions = new ServiceDescriptionCollection();
     this.schemas = new XmlSchemas();
     this.allSchemas = new XmlSchemas();
     this.options = System.Xml.Serialization.CodeGenerationOptions.GenerateOldAsync;
     this.abstractSchemas = new XmlSchemas();
     this.concreteSchemas = new XmlSchemas();
     Type[] protocolImporterTypes = WebServicesSection.Current.ProtocolImporterTypes;
     this.importers = new ProtocolImporter[protocolImporterTypes.Length];
     for (int i = 0; i < this.importers.Length; i++)
     {
         this.importers[i] = (ProtocolImporter) Activator.CreateInstance(protocolImporterTypes[i]);
         this.importers[i].Initialize(this);
     }
 }
Ejemplo n.º 6
0
 public ServiceDescriptionImporter()
 {
     this.serviceDescriptions = new ServiceDescriptionCollection();
     this.schemas             = new XmlSchemas();
     this.allSchemas          = new XmlSchemas();
     this.options             = System.Xml.Serialization.CodeGenerationOptions.GenerateOldAsync;
     this.abstractSchemas     = new XmlSchemas();
     this.concreteSchemas     = new XmlSchemas();
     Type[] protocolImporterTypes = WebServicesSection.Current.ProtocolImporterTypes;
     this.importers = new ProtocolImporter[protocolImporterTypes.Length];
     for (int i = 0; i < this.importers.Length; i++)
     {
         this.importers[i] = (ProtocolImporter)Activator.CreateInstance(protocolImporterTypes[i]);
         this.importers[i].Initialize(this);
     }
 }
Ejemplo n.º 7
0
 System.Xml.Serialization.CodeGenerationOptions GetEnumValue_CodeGenerationOptions(string xmlName)
 {
     xmlName = xmlName.Trim();
     if (xmlName.Length == 0)
     {
         return((System.Xml.Serialization.CodeGenerationOptions) 0);
     }
     System.Xml.Serialization.CodeGenerationOptions sb = (System.Xml.Serialization.CodeGenerationOptions) 0;
     string[] enumNames = xmlName.Split(null);
     foreach (string name in enumNames)
     {
         if (name == string.Empty)
         {
             continue;
         }
         sb |= GetEnumValue_CodeGenerationOptions_Switch(name);
     }
     return(sb);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Generates the data contracts for given xsd file(s).
        /// </summary>
        public CodeNamespace GenerateCode()
        {
            CodeCompileUnit codeCompileUnit = new CodeCompileUnit();
            CodeNamespace   codeNamespace   = new CodeNamespace(options.ClrNamespace);

            codeCompileUnit.Namespaces.Add(codeNamespace);

            // Build the code generation options.
            GenerationOptions generationOptions = GenerationOptions.None;

            if (options.GenerateProperties)
            {
                generationOptions |= GenerationOptions.GenerateProperties;
            }

            if (options.EnableDataBinding)
            {
                generationOptions |= GenerationOptions.EnableDataBinding;
            }
            if (options.GenerateOrderIdentifiers)
            {
                generationOptions |= GenerationOptions.GenerateOrder;
            }

            // Build the CodeDom object graph.
            XmlCodeExporter   codeExporter    = new XmlCodeExporter(codeNamespace, codeCompileUnit, generationOptions, null);
            CodeIdentifiers   codeIdentifiers = new CodeIdentifiers();
            ImportContext     importContext   = new ImportContext(codeIdentifiers, false);
            XmlSchemaImporter schemaimporter  = new XmlSchemaImporter(schemas, generationOptions, codeProvider, importContext);

            for (int si = 0; si < schemas.Count; si++)
            {
                XmlSchema   schema      = schemas[si];
                IEnumerator enumerator  = schema.Elements.Values.GetEnumerator();
                IEnumerator enumerator2 = schema.SchemaTypes.Values.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        XmlSchemaElement element = (XmlSchemaElement)enumerator.Current;
                        if (element.IsAbstract)
                        {
                            continue;
                        }

                        XmlTypeMapping typemapping = schemaimporter.ImportTypeMapping(element.QualifiedName);
                        codeExporter.ExportTypeMapping(typemapping);
                    }
                    while (enumerator2.MoveNext())
                    {
                        XmlSchemaType type = (XmlSchemaType)enumerator2.Current;
                        if (CouldBeAnArray(type))
                        {
                            continue;
                        }

                        XmlTypeMapping typemapping = schemaimporter.ImportSchemaType(type.QualifiedName);
                        codeExporter.ExportTypeMapping(typemapping);
                    }
                }
                finally
                {
                    IDisposable disposableobject = enumerator as IDisposable;
                    if (disposableobject != null)
                    {
                        disposableobject.Dispose();
                    }
                    IDisposable disposableobject2 = enumerator2 as IDisposable;
                    if (disposableobject2 != null)
                    {
                        disposableobject2.Dispose();
                    }
                }
            }
            if (codeNamespace.Types.Count == 0)
            {
                throw new Exception("No types were generated.");
            }

            return(codeNamespace);
        }