UdpMessageProperty.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.ServiceModel.Discovery / System / ServiceModel / Channels / UdpMessageProperty.cs / 1305376 / UdpMessageProperty.cs

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

namespace System.ServiceModel.Channels 
{
    using System.Runtime; 
    using System.ServiceModel.Discovery; 

    class UdpMessageProperty : IMessageProperty 
    {
        const string PropertyName = "UdpMessageProperty";

        public UdpMessageProperty(int interfaceIndex) 
        {
            this.InterfaceIndex = interfaceIndex; 
        } 

        UdpMessageProperty(UdpMessageProperty other) 
        {
            this.InterfaceIndex = other.InterfaceIndex;
        }
 
        public static string Name
        { 
            get { return PropertyName; } 
        }
 
        public int InterfaceIndex
        {
            get;
            private set; 
        }
 
        public static bool TryGet(Message message, out UdpMessageProperty property) 
        {
            if (message == null) 
            {
                throw FxTrace.Exception.ArgumentNull("message");
            }
 
            return TryGet(message.Properties, out property);
        } 
 
        public static bool TryGet(MessageProperties properties, out UdpMessageProperty property)
        { 
            if (properties == null)
            {
                throw FxTrace.Exception.ArgumentNull("properties");
            } 

            object value = null; 
            if (properties.TryGetValue(PropertyName, out value)) 
            {
                property = value as UdpMessageProperty; 
            }
            else
            {
                property = null; 
            }
            return property != null; 
        } 

        public void AddTo(Message message) 
        {
            if (message == null)
            {
                throw FxTrace.Exception.ArgumentNull("message"); 
            }
 
            AddTo(message.Properties); 
        }
 
        public void AddTo(MessageProperties properties)
        {
            if (properties == null)
            { 
                throw FxTrace.Exception.ArgumentNull("properties");
            } 
 
            properties.Add(UdpMessageProperty.Name, this);
        } 

        public IMessageProperty CreateCopy()
        {
            return new UdpMessageProperty(this); 
        }
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.


                        

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