EndpointAddressAugust2004.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / EndpointAddressAugust2004.cs / 1 / EndpointAddressAugust2004.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel
{ 
    using System;
    using System.ServiceModel.Channels; 
    using System.Xml; 
    using System.Xml.Schema;
    using System.Xml.Serialization; 
    using System.Collections;
    using System.Text;
    using System.IO;
 
    [XmlSchemaProvider("GetSchema")]
    [XmlRoot(AddressingStrings.EndpointReference, Namespace = Addressing200408Strings.Namespace)] 
    public class EndpointAddressAugust2004 : IXmlSerializable 
    {
        static XmlSchema eprSchema; 
        static XmlQualifiedName eprType;

        EndpointAddress address;
 
        // for IXmlSerializable
        EndpointAddressAugust2004() 
        { 
            this.address = null;
        } 

        EndpointAddressAugust2004(EndpointAddress address)
        {
            this.address = address; 
        }
 
        public static EndpointAddressAugust2004 FromEndpointAddress(EndpointAddress address) 
        {
            if (address == null) 
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("address");
            }
            return new EndpointAddressAugust2004(address); 
        }
 
        public EndpointAddress ToEndpointAddress() 
        {
            return this.address; 
        }

        void IXmlSerializable.ReadXml(XmlReader reader)
        { 
            this.address = EndpointAddress.ReadFrom(AddressingVersion.WSAddressingAugust2004, XmlDictionaryReader.CreateDictionaryReader(reader));
        } 
 
        void IXmlSerializable.WriteXml(XmlWriter writer)
        { 
            this.address.WriteContentsTo(AddressingVersion.WSAddressingAugust2004, XmlDictionaryWriter.CreateDictionaryWriter(writer));
        }

        static XmlSchema EprSchema 
        {
            get 
            { 
                if (eprSchema == null)
                { 
                    XmlTextReader reader = new XmlTextReader(new StringReader(Schema));
                    XmlSchema xmlSchema = XmlSchema.Read(reader, null);
                    eprSchema = xmlSchema;
                } 
                return eprSchema;
            } 
        } 

        static XmlQualifiedName EprType 
        {
            get
            {
                if (eprType == null) 
                    eprType = new XmlQualifiedName(AddressingStrings.EndpointReferenceType, Addressing200408Strings.Namespace);
                return eprType; 
            } 
        }
 
        public static XmlQualifiedName GetSchema(XmlSchemaSet xmlSchemaSet)
        {
            if (xmlSchemaSet == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlSchemaSet"); 
            XmlQualifiedName eprType = EprType;
            ICollection schemas = xmlSchemaSet.Schemas(Addressing200408Strings.Namespace); 
            if (schemas == null || schemas.Count == 0) 
                xmlSchemaSet.Add(EprSchema);
            else 
            {
                XmlSchema schemaToAdd = null;
                foreach (XmlSchema xmlSchema in schemas)
                { 
                    if (xmlSchema.SchemaTypes.Contains(eprType))
                    { 
                        schemaToAdd = null; 
                        break;
                    } 
                    else
                        schemaToAdd = xmlSchema;
                }
                if (schemaToAdd != null) 
                {
                    foreach (XmlQualifiedName prefixNsPair in EprSchema.Namespaces.ToArray()) 
                        schemaToAdd.Namespaces.Add(prefixNsPair.Name, prefixNsPair.Namespace); 
                    foreach (XmlSchemaObject schemaObject in EprSchema.Items)
                        schemaToAdd.Items.Add(schemaObject); 
                    xmlSchemaSet.Reprocess(schemaToAdd);
                }
            }
            return eprType; 
        }
 
        XmlSchema IXmlSerializable.GetSchema() 
        {
            return null; 
        }

        const string Schema =
@" 
  
   
   
  
     
      
      
      
       
      
       
         
          
 					 If ""Policy"" elements from namespace ""http://schemas.xmlsoap.org/ws/2002/12/policy#policy"" are used, they must appear first (before any extensibility elements). 
					
        
      
     
    
   
   
    
       
    
  
  
     
      
     
   
  
     
      
        
        
       
    
   
   
  
   
  
  
  
   
  
   
     
      
         
        
      
    
   
  
     
       
    
   
  
  
    
       
        
       
     
  
   
    
      
      
       
      
       
     
  
   
  
  
    
       
        
       
     
  
   
    
      
        
       
    
   
"; 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK