EndpointAddress10.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 / EndpointAddress10.cs / 1 / EndpointAddress10.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 = Addressing10Strings.Namespace)] 
    public class EndpointAddress10 : IXmlSerializable 
    {
        static XmlSchema eprSchema; 
        static XmlQualifiedName eprType;

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

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

        void IXmlSerializable.ReadXml(XmlReader reader)
        { 
            this.address = EndpointAddress.ReadFrom(AddressingVersion.WSAddressing10, XmlDictionaryReader.CreateDictionaryReader(reader));
        } 
 
        void IXmlSerializable.WriteXml(XmlWriter writer)
        { 
            this.address.WriteContentsTo(AddressingVersion.WSAddressing10, 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, Addressing10Strings.Namespace);
                return eprType; 
            } 
        }
 
        public static XmlQualifiedName GetSchema(XmlSchemaSet xmlSchemaSet)
        {
            if (xmlSchemaSet == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlSchemaSet"); 
            XmlQualifiedName eprType = EprType;
            ICollection schemas = xmlSchemaSet.Schemas(Addressing10Strings.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 =
@" 

     
 
    
     
        
            
            
             
            
         
         
    
 
    
        
            
         
        
     
 
    
     
        
            
        
         
    
 
     
    
     
        
            
                
                 
            
         
     

     
        
    

     
        
             
         
    
 
    
    
    
     
    
 
     
        
             
                
            
        
     

     
 
    
 
    
        
    
 
    
         
             
            
             
            
            
            
             
            
             
             
            
         
    

    
     
        
             
                 
            
         
    

    
     
        
             
                 
            
         
    

    
     
        
             
         
        
     

    

     
    
         
             
            
         
        
    

"; 
    }
} 

// 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