WebOperationContext.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 / NetFx35 / System.ServiceModel.Web / System / ServiceModel / Web / WebOperationContext.cs / 1 / WebOperationContext.cs

                            //------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------
#pragma warning disable 1634, 1691
 
namespace System.ServiceModel.Web
{ 
    using System; 
    using System.Globalization;
    using System.Diagnostics.CodeAnalysis; 
    using System.ServiceModel;
    using System.ServiceModel.Channels;
    using System.ServiceModel.Description;
    using System.ServiceModel.Dispatcher; 
    using System.Net;
    using System.Collections.ObjectModel; 
    using System.Collections.Specialized; 

    public class WebOperationContext : IExtension 
    {
        OperationContext operationContext;
        public WebOperationContext(OperationContext operationContext)
        { 
            if (operationContext == null)
            { 
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationContext"); 
            }
            this.operationContext = operationContext; 
#pragma warning disable 56506 // [....], operationContext.Extensions is never null
            if (operationContext.Extensions.Find() == null)
            {
                operationContext.Extensions.Add(this); 
            }
#pragma warning enable 56506 
        } 

        public static WebOperationContext Current 
        {
            get
            {
                if (OperationContext.Current == null) 
                {
                    return null; 
                } 
                WebOperationContext existing = OperationContext.Current.Extensions.Find();
                if (existing != null) 
                {
                    return existing;
                }
                return new WebOperationContext(OperationContext.Current); 
            }
        } 
 
        public IncomingWebRequestContext IncomingRequest
        { get { return new IncomingWebRequestContext(this.operationContext); } } 
        public IncomingWebResponseContext IncomingResponse
        { get { return new IncomingWebResponseContext(this.operationContext); } }

        public OutgoingWebRequestContext OutgoingRequest 
        { get { return new OutgoingWebRequestContext(this.operationContext); } }
        public OutgoingWebResponseContext OutgoingResponse 
        { get { return new OutgoingWebResponseContext(this.operationContext); } } 

        public void Attach(OperationContext owner) 
        {
        }
        public void Detach(OperationContext owner)
        { 
        }
    } 
} 


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