WebReferenceOptionsSerializer.cs :  » 2.6.4-mono-.net-core » System.Web » System » Web » Services » Description » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » 2.6.4 mono .net core » System.Web 
System.Web » System » Web » Services » Description » WebReferenceOptionsSerializer.cs
#if NET_2_0
using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Text;
using System.Collections;
using System.Globalization;

namespace System.Web.Services.Description{
  internal class WebReferenceOptionsReader : XmlSerializationReader
  {
    public object ReadRoot_WebReferenceOptions ()
    {
      Reader.MoveToContent();
      if (Reader.LocalName != "webReferenceOptions" || Reader.NamespaceURI != "http://microsoft.com/webReference/")
        throw CreateUnknownNodeException();
      return ReadObject_webReferenceOptions (true, true);
    }

    public System.Web.Services.Description.WebReferenceOptions ReadObject_webReferenceOptions (bool isNullable, bool checkType)
    {
      System.Web.Services.Description.WebReferenceOptions ob = null;
      if (isNullable && ReadNull()) return null;

      if (checkType) 
      {
        System.Xml.XmlQualifiedName t = GetXsiType();
        if (t == null)
        { }
        else if (t.Name != "webReferenceOptions" || t.Namespace != "http://microsoft.com/webReference/")
          throw CreateUnknownTypeException(t);
      }

      ob = new System.Web.Services.Description.WebReferenceOptions ();

      Reader.MoveToElement();

      ob.@CodeGenerationOptions = ((System.Xml.Serialization.CodeGenerationOptions) System.Xml.Serialization.CodeGenerationOptions.GenerateOldAsync);
      ob.@Style = ((System.Web.Services.Description.ServiceDescriptionImportStyle) System.Web.Services.Description.ServiceDescriptionImportStyle.Client);
      while (Reader.MoveToNextAttribute())
      {
        if (IsXmlnsAttribute (Reader.Name)) {
        }
        else {
          UnknownNode (ob);
        }
      }

      Reader.MoveToElement();
      if (Reader.IsEmptyElement) {
        Reader.Skip ();
        return ob;
      }

      Reader.ReadStartElement();
      Reader.MoveToContent();

      bool b0=false, b1=false, b2=false, b3=false;

      while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
      {
        if (Reader.NodeType == System.Xml.XmlNodeType.Element) 
        {
          if (Reader.LocalName == "style" && Reader.NamespaceURI == "http://microsoft.com/webReference/" && !b2) {
            b2 = true;
            ob.@Style = GetEnumValue_ServiceDescriptionImportStyle (Reader.ReadElementString ());
          }
          else if (Reader.LocalName == "verbose" && Reader.NamespaceURI == "http://microsoft.com/webReference/" && !b3) {
            b3 = true;
            ob.@Verbose = XmlConvert.ToBoolean (Reader.ReadElementString ());
          }
          else if (Reader.LocalName == "codeGenerationOptions" && Reader.NamespaceURI == "http://microsoft.com/webReference/" && !b0) {
            b0 = true;
            ob.@CodeGenerationOptions = GetEnumValue_CodeGenerationOptions (Reader.ReadElementString ());
          }
          else if (Reader.LocalName == "schemaImporterExtensions" && Reader.NamespaceURI == "http://microsoft.com/webReference/" && !b1) {
            if (((object)ob.@SchemaImporterExtensions) == null)
              throw CreateReadOnlyCollectionException ("System.Collections.Specialized.StringCollection");
            if (Reader.IsEmptyElement) {
              Reader.Skip();
            } else {
              int n4 = 0;
              Reader.ReadStartElement();
              Reader.MoveToContent();

              while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
              {
                if (Reader.NodeType == System.Xml.XmlNodeType.Element) 
                {
                  if (Reader.LocalName == "type" && Reader.NamespaceURI == "http://microsoft.com/webReference/") {
                    if (((object)ob.@SchemaImporterExtensions) == null)
                      throw CreateReadOnlyCollectionException ("System.Collections.Specialized.StringCollection");
                    ob.@SchemaImporterExtensions.Add (Reader.ReadElementString ());
                    n4++;
                  }
                  else UnknownNode (null);
                }
                else UnknownNode (null);

                Reader.MoveToContent();
              }
              ReadEndElement();
            }
            b1 = true;
          }
          else {
            UnknownNode (ob);
          }
        }
        else
          UnknownNode(ob);

        Reader.MoveToContent();
      }

      ReadEndElement();

      return ob;
    }

    public System.Web.Services.Description.ServiceDescriptionImportStyle ReadObject_ServiceDescriptionImportStyle (bool isNullable, bool checkType)
    {
      Reader.ReadStartElement ();
      System.Web.Services.Description.ServiceDescriptionImportStyle res = GetEnumValue_ServiceDescriptionImportStyle (Reader.ReadString());
      if (Reader.NodeType != XmlNodeType.None)
      Reader.ReadEndElement ();
      return res;
    }

    System.Web.Services.Description.ServiceDescriptionImportStyle GetEnumValue_ServiceDescriptionImportStyle (string xmlName)
    {
      switch (xmlName)
      {
        case "client": return System.Web.Services.Description.ServiceDescriptionImportStyle.Client;
        case "server": return System.Web.Services.Description.ServiceDescriptionImportStyle.Server;
        case "serverInterface": return System.Web.Services.Description.ServiceDescriptionImportStyle.ServerInterface;
        default:
          throw CreateUnknownConstantException (xmlName, typeof(System.Web.Services.Description.ServiceDescriptionImportStyle));
      }
    }

    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;
    }

    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;
    }

    System.Xml.Serialization.CodeGenerationOptions GetEnumValue_CodeGenerationOptions_Switch (string xmlName)
    {
      switch (xmlName)
      {
        case "properties": return System.Xml.Serialization.CodeGenerationOptions.GenerateProperties;
        case "newAsync": return System.Xml.Serialization.CodeGenerationOptions.GenerateNewAsync;
        case "oldAsync": return System.Xml.Serialization.CodeGenerationOptions.GenerateOldAsync;
        case "order": return System.Xml.Serialization.CodeGenerationOptions.GenerateOrder;
        case "enableDataBinding": return System.Xml.Serialization.CodeGenerationOptions.EnableDataBinding;
        default:
          throw CreateUnknownConstantException (xmlName, typeof(System.Xml.Serialization.CodeGenerationOptions));
      }
    }

    protected override void InitCallbacks ()
    {
    }

    protected override void InitIDs ()
    {
    }

  }

  internal class WebReferenceOptionsWriter : XmlSerializationWriter
  {
    const string xmlNamespace = "http://www.w3.org/2000/xmlns/";
    public void WriteRoot_WebReferenceOptions (object o)
    {
      WriteStartDocument ();
      System.Web.Services.Description.WebReferenceOptions ob = (System.Web.Services.Description.WebReferenceOptions) o;
      TopLevelElement ();
      WriteObject_webReferenceOptions (ob, "webReferenceOptions", "http://microsoft.com/webReference/", true, false, true);
    }

    void WriteObject_webReferenceOptions (System.Web.Services.Description.WebReferenceOptions ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
    {
      if (((object)ob) == null)
      {
        if (isNullable)
          WriteNullTagLiteral(element, namesp);
        return;
      }

      System.Type type = ob.GetType ();
      if (type == typeof(System.Web.Services.Description.WebReferenceOptions))
      { }
      else {
        throw CreateUnknownTypeException (ob);
      }

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

      if (needType) WriteXsiType("webReferenceOptions", "http://microsoft.com/webReference/");

      if (ob.@CodeGenerationOptions != ((System.Xml.Serialization.CodeGenerationOptions) System.Xml.Serialization.CodeGenerationOptions.GenerateOldAsync)) {
        WriteElementString ("codeGenerationOptions", "http://microsoft.com/webReference/", GetEnumValue_CodeGenerationOptions (ob.@CodeGenerationOptions));
      }
      if (ob.@SchemaImporterExtensions != null) {
        WriteStartElement ("schemaImporterExtensions", "http://microsoft.com/webReference/", ob.@SchemaImporterExtensions);
        for (int n5 = 0; n5 < ob.@SchemaImporterExtensions.Count; n5++) {
          WriteElementString ("type", "http://microsoft.com/webReference/", ob.@SchemaImporterExtensions[n5]);
        }
        WriteEndElement (ob.@SchemaImporterExtensions);
      }
      if (ob.@Style != ((System.Web.Services.Description.ServiceDescriptionImportStyle) System.Web.Services.Description.ServiceDescriptionImportStyle.Client)) {
        WriteElementString ("style", "http://microsoft.com/webReference/", GetEnumValue_ServiceDescriptionImportStyle (ob.@Style));
      }
      WriteElementString ("verbose", "http://microsoft.com/webReference/", (ob.@Verbose?"true":"false"));
      if (writeWrappingElem) WriteEndElement (ob);
    }

    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);
    }

    static readonly string[] _xmlNamesCodeGenerationOptions = { "properties","newAsync","oldAsync","order","enableDataBinding" };
    static readonly long[] _valuesCodeGenerationOptions = { 1L,2L,4L,8L,16L };

    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);
      }
    }

    void WriteObject_ServiceDescriptionImportStyle (System.Web.Services.Description.ServiceDescriptionImportStyle ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
    {
      System.Type type = ob.GetType ();
      if (type == typeof(System.Web.Services.Description.ServiceDescriptionImportStyle))
      { }
      else {
        throw CreateUnknownTypeException (ob);
      }

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

      if (needType) WriteXsiType("ServiceDescriptionImportStyle", "http://microsoft.com/webReference/");

      Writer.WriteString (GetEnumValue_ServiceDescriptionImportStyle (ob));
      if (writeWrappingElem) WriteEndElement (ob);
    }

    string GetEnumValue_ServiceDescriptionImportStyle (System.Web.Services.Description.ServiceDescriptionImportStyle val)
    {
      switch (val) {
        case System.Web.Services.Description.ServiceDescriptionImportStyle.Client: return "client";
        case System.Web.Services.Description.ServiceDescriptionImportStyle.Server: return "server";
        case System.Web.Services.Description.ServiceDescriptionImportStyle.ServerInterface: return "serverInterface";
        default: throw CreateInvalidEnumValueException ((long) val, typeof (System.Web.Services.Description.ServiceDescriptionImportStyle).FullName);
      }
    }

    protected override void InitCallbacks ()
    {
    }

  }


  internal class WebReferenceOptionsBaseSerializer : System.Xml.Serialization.XmlSerializer
  {
    protected override System.Xml.Serialization.XmlSerializationReader CreateReader () {
      return new WebReferenceOptionsReader ();
    }

    protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter () {
      return new WebReferenceOptionsWriter ();
    }

    public override bool CanDeserialize (System.Xml.XmlReader xmlReader) {
      return true;
    }
  }

  internal sealed class webReferenceOptionsSerializer : WebReferenceOptionsBaseSerializer
  {
    protected override void Serialize (object obj, System.Xml.Serialization.XmlSerializationWriter writer) {
      ((WebReferenceOptionsWriter)writer).WriteRoot_WebReferenceOptions(obj);
    }

    protected override object Deserialize (System.Xml.Serialization.XmlSerializationReader reader) {
      return ((WebReferenceOptionsReader)reader).ReadRoot_WebReferenceOptions();
    }
  }

  internal class WebReferenceOptionsSerializerImplementation : System.Xml.Serialization.XmlSerializerImplementation
  {
    System.Collections.Hashtable readMethods = null;
    System.Collections.Hashtable writeMethods = null;
    System.Collections.Hashtable typedSerializers = null;

    public override System.Xml.Serialization.XmlSerializationReader Reader {
      get {
        return new WebReferenceOptionsReader();
      }
    }

    public override System.Xml.Serialization.XmlSerializationWriter Writer {
      get {
        return new WebReferenceOptionsWriter();
      }
    }

    public override System.Collections.Hashtable ReadMethods {
      get {
        lock (this) {
          if (readMethods == null) {
            readMethods = new System.Collections.Hashtable ();
            readMethods.Add (@"", @"ReadRoot_WebReferenceOptions");
          }
          return readMethods;
        }
      }
    }

    public override System.Collections.Hashtable WriteMethods {
      get {
        lock (this) {
          if (writeMethods == null) {
            writeMethods = new System.Collections.Hashtable ();
            writeMethods.Add (@"", @"WriteRoot_WebReferenceOptions");
          }
          return writeMethods;
        }
      }
    }

    public override System.Collections.Hashtable TypedSerializers {
      get {
        lock (this) {
          if (typedSerializers == null) {
            typedSerializers = new System.Collections.Hashtable ();
            typedSerializers.Add (@"", new webReferenceOptionsSerializer());
          }
          return typedSerializers;
        }
      }
    }

    public override XmlSerializer GetSerializer (Type type)
    {
      switch (type.FullName) {
      case "System.Web.Services.Description.WebReferenceOptions":
        return (XmlSerializer) TypedSerializers [""];

      }
      return base.GetSerializer (type);
    }

    public override bool CanSerialize (System.Type type) {
      if (type == typeof(System.Web.Services.Description.WebReferenceOptions)) return true;
      return false;
    }
  }

}
#endif
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.