WebHttpBindingCollectionElement.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 / Configuration / WebHttpBindingCollectionElement.cs / 2 / WebHttpBindingCollectionElement.cs

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

namespace System.ServiceModel.Configuration 
{
    using System.Configuration; 
    using System.Web.Configuration; 
    using System.Web.Hosting;
    using System.ServiceModel; 
    using System.ServiceModel.Channels;
    using System.Runtime.CompilerServices;

    public partial class WebHttpBindingCollectionElement : StandardBindingCollectionElement 
    {
 
        protected internal override Binding GetDefault() 
        {
            return new WebHttpBinding(); 
        }


        internal static WebHttpBindingCollectionElement GetBindingCollectionElement() 
        {
            BindingCollectionElement retval = null; 
            BindingsSection bindings = null; 
            string sectionPath = "system.serviceModel/bindings";
 
            if (ServiceHostingEnvironment.IsHosted)
            {
                bindings = GetSectionFromWebConfiguration(sectionPath);
            } 
            else
            { 
                bindings = (BindingsSection) ConfigurationManager.GetSection(sectionPath); 
            }
 
            retval = bindings[WebHttpBinding.WebHttpBindingConfigurationStrings.WebHttpBindingCollectionElementName];

            return (WebHttpBindingCollectionElement) retval;
        } 

        [MethodImpl(MethodImplOptions.NoInlining)] 
        static BindingsSection GetSectionFromWebConfiguration(string sectionPath) 
        {
            if (HostingEnvironment.ApplicationVirtualPath != null) 
            {
                return (BindingsSection)WebConfigurationManager.GetSection(sectionPath, HostingEnvironment.ApplicationVirtualPath);
            }
            else 
            {
                return (BindingsSection)WebConfigurationManager.GetSection(sectionPath); 
            } 
        }
    } 
}

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