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

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

namespace System.ServiceModel.Dispatcher 
{
    using System.Collections.Generic; 
    using System.ServiceModel.Channels; 
    using System.Runtime.Serialization;
 
    class EndpointFilterProvider
    {
        SynchronizedCollection initiatingActions;
        object mutex; 

        public EndpointFilterProvider(params string[] initiatingActions) 
        { 
            this.mutex = new object();
            this.initiatingActions = new SynchronizedCollection(this.mutex, initiatingActions); 
        }

        public SynchronizedCollection InitiatingActions
        { 
            get { return this.initiatingActions; }
        } 
 
        public MessageFilter CreateFilter(out int priority)
        { 
            lock (this.mutex)
            {
                priority = 1;
                if (initiatingActions.Count == 0) 
                    return new MatchNoneMessageFilter();
 
                string[] actions = new string[initiatingActions.Count]; 
                int index = 0;
                for (int i = 0; i < initiatingActions.Count; i++) 
                {
                    string currentAction = initiatingActions[i];
                    if (currentAction == MessageHeaders.WildcardAction)
                    { 
                        priority = 0;
                        return new MatchAllMessageFilter(); 
                    } 
                    actions[index] = currentAction;
                    ++index; 
                }

                return new ActionMessageFilter(actions);
            } 
        }
    } 
} 


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