DnsEndpointIdentity.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 / DnsEndpointIdentity.cs / 1 / DnsEndpointIdentity.cs

                            //---------------------------------------------------------- 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------

namespace System.ServiceModel 
{
    using System; 
    using System.IdentityModel.Claims; 
    using System.IdentityModel.Policy;
    using System.Xml; 
    using System.Xml.Serialization;

    public class DnsEndpointIdentity : EndpointIdentity
    { 
        public DnsEndpointIdentity(string dnsName)
        { 
            if (dnsName == null) 
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dnsName");
 
            base.Initialize(Claim.CreateDnsClaim(dnsName));
        }

        public DnsEndpointIdentity(Claim identity) 
        {
            if (identity == null) 
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("identity"); 

            // PreSharp Bug: Parameter 'identity.ResourceType' to this public method must be validated: A null-dereference can occur here. 
            #pragma warning suppress 56506 // Claim.ClaimType will never return null
            if (!identity.ClaimType.Equals(ClaimTypes.Dns))
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.UnrecognizedClaimTypeForIdentity, identity.ClaimType, ClaimTypes.Dns));
 
            base.Initialize(identity);
        } 
 
        internal override void WriteContentsTo(XmlDictionaryWriter writer)
        { 
            if (writer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");

            writer.WriteElementString(XD.AddressingDictionary.Dns, XD.AddressingDictionary.IdentityExtensionNamespace, (string)this.IdentityClaim.Resource); 
        }
    } 
} 

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