EndpointDispatcher(EndpointDispatcher baseEndpoint, IEnumerable<AddressHeader> headers)
        {
            EndpointAddressBuilder builder = new EndpointAddressBuilder(baseEndpoint.EndpointAddress);
            foreach (AddressHeader h in headers)
            {
                builder.Headers.Add(h);
            }
            EndpointAddress address = builder.ToEndpointAddress();

            this.addressFilter = new EndpointAddressMessageFilter(address);
            // channelDispatcher is Attached
            this.contractFilter = baseEndpoint.ContractFilter;
            this.contractName = baseEndpoint.ContractName;
            this.contractNamespace = baseEndpoint.ContractNamespace;
            this.dispatchRuntime = baseEndpoint.DispatchRuntime;
            // endpointFilter is lazy
            this.filterPriority = baseEndpoint.FilterPriority + 1;
            this.originalAddress = address;
            if (PerformanceCounters.PerformanceCountersEnabled)
            {
                this.perfCounterId = baseEndpoint.perfCounterId;
                this.perfCounterBaseId = baseEndpoint.perfCounterBaseId;
            }
            this.id = baseEndpoint.id;
        }
Exemplo n.º 2
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
   if (dispatchRuntime == null)
     throw new ArgumentNullException("dispatchRuntime");
   dispatchRuntime.InstanceProvider = this.instanceProvider;
   dispatchRuntime.InstanceContextInitializers.Add((IInstanceContextInitializer) new UnityInstanceContextInitializer());
 }
 /// <summary>
 /// 注册 服务实例创建提供者,将基于PIAB的实例生成器注入WCF扩展
 /// </summary>
 /// <param name="contractDescription"></param>
 /// <param name="endpoint"></param>
 /// <param name="dispatchRuntime"></param>
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint,
                                   DispatchRuntime dispatchRuntime)
 {
     Type serviceContractType = contractDescription.ContractType;
     dispatchRuntime.InstanceProvider = new PolicyInjectionInstanceProvider(serviceContractType,
                                                                            this.PolicyInjectorName);
 }
 public void ApplyDispatchBehavior(
   ContractDescription contractDescription,
   ServiceEndpoint endpoint,
   DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.InstanceProvider = this;
 }
		void IContractBehavior.ApplyDispatchBehavior (
			ContractDescription description,
			ServiceEndpoint endpoint,
			DispatchRuntime dispatch)
		{
			throw new NotImplementedException ();
		}
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
 {
     if (dispatch.ClientRuntime != null)
     {
         dispatch.ClientRuntime.OperationSelector = new MethodInfoOperationSelector(description, MessageDirection.Output);
     }
 }
        public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
        {
            var behavior =
                dispatchRuntime.ChannelDispatcher.Host.Description.FindBehavior
                        <WebAuthenticationConfigurationBehavior,
                         WebAuthenticationConfigurationAttribute>(b => b.BaseBehavior);

            if (behavior == null)
                behavior = contractDescription.FindBehavior
                        <WebAuthenticationConfigurationBehavior,
                         WebAuthenticationConfigurationAttribute>(b => b.BaseBehavior);

            if (behavior == null)
                throw new ServiceAuthenticationConfigurationMissingException();

            var authorizationBehavior =
                dispatchRuntime.ChannelDispatcher.Host.Description.FindBehavior
                        <WebAuthorizationConfigurationBehavior,
                        WebAuthorizationConfigurationAttribute>(b => b.BaseBehavior);

            Type authorizationPolicy = null;
            if (authorizationBehavior != null)
                authorizationPolicy = authorizationBehavior.AuthorizationPolicyType;

            foreach (var endpointDispatcher in dispatchRuntime.ChannelDispatcher.Endpoints)
                endpointDispatcher.DispatchRuntime.MessageInspectors.Add(
                    new ServiceAuthenticationInspector(
                        behavior.ThrowIfNull().AuthenticationHandler,
                        behavior.UsernamePasswordValidatorType,
                        behavior.RequireSecureTransport,
                        behavior.Source,
                        authorizationPolicy));
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="contractDescription"></param>
 /// <param name="endpoint"></param>
 /// <param name="dispatchRuntime">The runtime object that can be used to modify the default service behavior.</param>
 public void ApplyDispatchBehavior(
     ContractDescription contractDescription,
     ServiceEndpoint endpoint,
     DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.InstanceProvider = this;   // set the provider to manage service objects instantiation
 }
Exemplo n.º 9
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint,
                                   DispatchRuntime dispatchRuntime)
 {
     if (!TypeHelper.IsTypeOf<IDispatchMessageInspector>(_inspectorType)) return;
     var inspector = TypeHelper.CreateInstance<IDispatchMessageInspector>(_inspectorType);
     dispatchRuntime.MessageInspectors.Add(inspector);
 }
Exemplo n.º 10
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     foreach (DispatchOperation op in dispatchRuntime.Operations)
     {
         op.ParameterInspectors.Add(new ParameterValidatorBehavior(ThrowErrorOnFirstError, ThrowErrorAfterValidation));
     }
 }
 /// <summary>
 /// Implements a modification or extension of the client across a contract.
 /// </summary>
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint,
                                   DispatchRuntime dispatchRuntime)
 {
     foreach (OperationDescription od in contractDescription.Operations)
     {
         InjectNetDataContractSerializer(od);
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Implements a modification or extension of the client across a contract.
        /// </summary>
        /// <param name="contractDescription">The contract description to be modified.</param>
        /// <param name="endpoint">The endpoint that exposes the contract.</param>
        /// <param name="dispatchRuntime">The dispatch runtime that controls service execution.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="dispatchRuntime"/> is <c>null</c>.</exception>
        public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint,
            DispatchRuntime dispatchRuntime)
        {
            Argument.IsNotNull("dispatchRuntime", dispatchRuntime);

            dispatchRuntime.InstanceProvider = _instanceProvider;
            dispatchRuntime.InstanceContextInitializers.Add(new InstanceContextInitializer());
        }
 internal static TransactionBehavior CreateIfNeeded(DispatchRuntime dispatch)
 {
     if (NeedsTransactionBehavior(dispatch))
     {
         return new TransactionBehavior(dispatch);
     }
     return null;
 }
 public static SecurityImpersonationBehavior CreateIfNecessary(DispatchRuntime dispatch)
 {
     if (IsSecurityBehaviorNeeded(dispatch))
     {
         return new SecurityImpersonationBehavior(dispatch);
     }
     return null;
 }
 public static TerminatingOperationBehavior CreateIfNecessary(DispatchRuntime dispatch)
 {
     if (IsTerminatingOperationBehaviorNeeded(dispatch))
     {
         return new TerminatingOperationBehavior();
     }
     return null;
 }
Exemplo n.º 16
0
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription description,ServiceEndpoint endpoint,DispatchRuntime dispatchRuntime)
 {
     PoolName = PoolName ?? "Pool executing endpoints of " + ServiceType;
      lock(typeof(ThreadPoolHelper))
      {
     ThreadPoolHelper.ApplyDispatchBehavior(ProvideSynchronizer(),PoolSize,ServiceType,PoolName,dispatchRuntime);
      }
 }
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription contract, ServiceEndpoint endpoint, DispatchRuntime runtime)
 {
     //if (s_Logger.IsDebugEnabled)
     //{
     //    s_Logger.DebugFormat("Applying dispatch ExceptionMarshallingBehavior to contract {0}", contract.ContractType.FullName);
     //}
     ApplyDispatchBehavior(runtime.ChannelDispatcher);
 }
Exemplo n.º 18
0
 public void ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
 {
     dispatch.InstanceProvider = new MEFInstanceProvider();
     lock (lockobject)
     {
         if (IOC.Container == null)
             IOC.Container = MEFInstanceProvider._container;
     }
 }
 public void ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
 {
     dispatch.InstanceProvider = new ComPlusInstanceProvider(this.info);
     dispatch.InstanceContextInitializers.Add(new ComPlusInstanceContextInitializer(this.info));
     foreach (DispatchOperation operation in dispatch.Operations)
     {
         operation.CallContextInitializers.Add(new ComPlusThreadInitializer(description, operation, this.info));
     }
 }
Exemplo n.º 20
0
 internal static IInstanceContextProvider GetProviderForMode(InstanceContextMode instanceMode, DispatchRuntime runtime)
 {
     switch (instanceMode)
     {
         case InstanceContextMode.PerSession:
             return new PerSessionInstanceContextProvider(runtime);
         default:
             throw new PlatformNotSupportedException();
     }
 }
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     foreach (OperationDescription description in contractDescription.Operations)
     {
         if (description.Behaviors.Find<WorkflowHostingOperationBehavior>() == null)
         {
             description.Behaviors.Add(new WorkflowHostingOperationBehavior((WorkflowHostingEndpoint) endpoint));
         }
     }
 }
        internal static void ApplyDispatchBehavior(Type type, string threadName, DispatchRuntime dispatch)
        {
            Debug.Assert(dispatch.SynchronizationContext == null);

            if (m_Contexts.ContainsKey(type) == false)
            {
                m_Contexts[type] = new AffinitySynchronizer(threadName);
            }
            dispatch.SynchronizationContext = m_Contexts[type];
        }
Exemplo n.º 23
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.ChannelDispatcher.ChannelInitializers.Add(new MyChannelInitializer(true));
     dispatchRuntime.ChannelDispatcher.ErrorHandlers.Add(new MyErrorHandler());
     dispatchRuntime.InstanceContextInitializers.Add(new MyInstanceContextInitializer());
     dispatchRuntime.InstanceContextProvider = new MyInstanceContextProvider(dispatchRuntime.InstanceContextProvider);
     dispatchRuntime.InstanceProvider = new MyInstanceProvider(dispatchRuntime.ChannelDispatcher.Host.Description.ServiceType);
     dispatchRuntime.MessageInspectors.Add(new MyDispatchMessageInspector());
     dispatchRuntime.OperationSelector = new MyDispatchOperationSelector();
 }
 private void ApplyAuthorizationPoliciesAndManager(DispatchRuntime behavior)
 {
     if (this.externalAuthorizationPolicies != null)
     {
         behavior.ExternalAuthorizationPolicies = this.externalAuthorizationPolicies;
     }
     if (this.serviceAuthorizationManager != null)
     {
         behavior.ServiceAuthorizationManager = this.serviceAuthorizationManager;
     }
 }
 private static bool IsTerminatingOperationBehaviorNeeded(DispatchRuntime dispatch)
 {
     for (int i = 0; i < dispatch.Operations.Count; i++)
     {
         DispatchOperation operation = dispatch.Operations[i];
         if (operation.IsTerminating)
         {
             return true;
         }
     }
     return false;
 }
 internal TransactionBehavior(DispatchRuntime dispatch)
 {
     this.isolation = ServiceBehaviorAttribute.DefaultIsolationLevel;
     this.timeout = TimeSpan.Zero;
     this.isConcurrent = (dispatch.ConcurrencyMode == ConcurrencyMode.Multiple) || (dispatch.ConcurrencyMode == ConcurrencyMode.Reentrant);
     this.dispatch = dispatch;
     this.isTransactedReceiveChannelDispatcher = dispatch.ChannelDispatcher.IsTransactedReceive;
     if (dispatch.ChannelDispatcher.TransactionIsolationLevelSet)
     {
         this.InitializeIsolationLevel(dispatch);
     }
     this.timeout = NormalizeTimeout(dispatch.ChannelDispatcher.TransactionTimeout);
 }
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     if (dispatchRuntime.ChannelDispatcher.Host.Description.Behaviors.Contains(typeof(WorkflowServiceBehavior)))
     {
         foreach (OperationDescription description in contractDescription.Operations)
         {
             if (description.Behaviors.Find<ControlOperationBehavior>() == null)
             {
                 description.Behaviors.Add(new ControlOperationBehavior(true));
             }
         }
     }
 }
 private SecurityImpersonationBehavior(DispatchRuntime dispatch)
 {
     this.principalPermissionMode = dispatch.PrincipalPermissionMode;
     this.impersonateCallerForAllOperations = dispatch.ImpersonateCallerForAllOperations;
     this.auditLevel = dispatch.MessageAuthenticationAuditLevel;
     this.auditLogLocation = dispatch.SecurityAuditLogLocation;
     this.suppressAuditFailure = dispatch.SuppressAuditFailure;
     if (dispatch.IsRoleProviderSet)
     {
         this.ApplyRoleProvider(dispatch);
     }
     this.domainNameMap = new Dictionary<string, string>(5, StringComparer.OrdinalIgnoreCase);
 }
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     //Only when DurableServiceBehavior is present ensure this endpoint operates in wrapped mode.
     if (dispatchRuntime.ChannelDispatcher.Host.Description.Behaviors.Contains(typeof(WorkflowServiceBehavior)))
     {
         foreach (OperationDescription operation in contractDescription.Operations)
         {
             if (operation.Behaviors.Find<ControlOperationBehavior>() == null)
             {
                 operation.Behaviors.Add(new ControlOperationBehavior(true));
             }
         }
     }
 }
Exemplo n.º 30
0
        internal InstanceBehavior(DispatchRuntime dispatch, ImmutableDispatchRuntime immutableRuntime)
        {
            this.useSession = dispatch.ChannelDispatcher.Session;
            this.immutableRuntime = immutableRuntime;
            this.host = (dispatch.ChannelDispatcher == null) ? null : dispatch.ChannelDispatcher.Host;
            this.initializers = EmptyArray<IInstanceContextInitializer>.ToArray(dispatch.InstanceContextInitializers);
            this.provider = dispatch.InstanceProvider;
            this.singleton = dispatch.SingletonInstanceContext;
            this.transactionAutoCompleteOnSessionClose = dispatch.TransactionAutoCompleteOnSessionClose;
            this.releaseServiceInstanceOnTransactionComplete = dispatch.ReleaseServiceInstanceOnTransactionComplete;
            this.isSynchronized = (dispatch.ConcurrencyMode != ConcurrencyMode.Multiple);
            this.instanceContextProvider = dispatch.InstanceContextProvider;

            if (this.provider == null)
            {
                ConstructorInfo constructor = null;
                if (dispatch.Type != null)
                {
                    constructor = InstanceBehavior.GetConstructor(dispatch.Type);
                }

                if (this.singleton == null)
                {
                    if (dispatch.Type != null && (dispatch.Type.IsAbstract || dispatch.Type.IsInterface))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxServiceTypeNotCreatable)));
                    }

                    if (constructor == null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxNoDefaultConstructor)));
                    }
                }

                if (constructor != null)
                {
                    if (this.singleton == null || !this.singleton.IsWellKnown)
                    {
                        InvokerUtil util = new InvokerUtil();
                        CreateInstanceDelegate creator = util.GenerateCreateInstanceDelegate(dispatch.Type, constructor);
                        this.provider = new InstanceProvider(creator);
                    }
                }
            }

            if (this.singleton != null)
            {
                this.singleton.Behavior = this;
            }
        }
 internal SingletonInstanceContextProvider(DispatchRuntime dispatchRuntime) : base(dispatchRuntime)
 {
     this.thisLock = new object();
 }
 protected override System.ServiceModel.Dispatcher.IDispatchMessageInspector[] CreateDispatchMessageInspectors(System.ServiceModel.Dispatcher.DispatchRuntime runtime)
 {
     return(new IDispatchMessageInspector[] { this });
 }
Exemplo n.º 33
0
 internal OperationCollection(DispatchRuntime outer)
     : base(outer.ThisLock)
 {
     _outer = outer;
 }
Exemplo n.º 34
0
 public UnhandledActionInvoker(DispatchRuntime dispatchRuntime)
 {
     _dispatchRuntime = dispatchRuntime;
 }
Exemplo n.º 35
0
        private bool DispatchAndReleasePump(RequestContext request, bool cleanThread, OperationContext currentOperationContext)
        {
            ServiceChannel     channel  = _requestInfo.Channel;
            EndpointDispatcher endpoint = _requestInfo.Endpoint;
            bool releasedPump           = false;

            try
            {
                DispatchRuntime dispatchBehavior = _requestInfo.DispatchRuntime;

                if (channel == null || dispatchBehavior == null)
                {
                    Fx.Assert("System.ServiceModel.Dispatcher.ChannelHandler.Dispatch(): (channel == null || dispatchBehavior == null)");
                    return(true);
                }

                EventTraceActivity eventTraceActivity = TraceDispatchMessageStart(request.RequestMessage);
                Message            message            = request.RequestMessage;

                DispatchOperationRuntime operation = dispatchBehavior.GetOperation(ref message);
                if (operation == null)
                {
                    Fx.Assert("ChannelHandler.Dispatch (operation == null)");
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "No DispatchOperationRuntime found to process message.")));
                }

                if (_shouldRejectMessageWithOnOpenActionHeader && message.Headers.Action == OperationDescription.SessionOpenedAction)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxNoEndpointMatchingAddressForConnectionOpeningMessage, message.Headers.Action, "Open")));
                }

                if (MessageLogger.LoggingEnabled)
                {
                    MessageLogger.LogMessage(ref message, (operation.IsOneWay ? MessageLoggingSource.ServiceLevelReceiveDatagram : MessageLoggingSource.ServiceLevelReceiveRequest) | MessageLoggingSource.LastChance);
                }

                bool hasOperationContextBeenSet;
                if (currentOperationContext != null)
                {
                    hasOperationContextBeenSet = true;
                    currentOperationContext.ReInit(request, message, channel);
                }
                else
                {
                    hasOperationContextBeenSet = false;
                    currentOperationContext    = new OperationContext(request, message, channel);
                }

                MessageRpc rpc = new MessageRpc(request, message, operation, channel,
                                                this, cleanThread, currentOperationContext, _requestInfo.ExistingInstanceContext, eventTraceActivity);

                TraceUtility.MessageFlowAtMessageReceived(message, currentOperationContext, eventTraceActivity, true);

                // These need to happen before Dispatch but after accessing any ChannelHandler
                // state, because we go multi-threaded after this until we reacquire pump mutex.
                ReleasePump();
                releasedPump = true;

                return(operation.Parent.Dispatch(ref rpc, hasOperationContextBeenSet));
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                return(this.HandleError(e, request, channel));
            }
            finally
            {
                if (!releasedPump)
                {
                    this.ReleasePump();
                }
            }
        }
Exemplo n.º 36
0
 internal ConcurrencyBehavior(DispatchRuntime runtime)
 {
     this.mode = runtime.ConcurrencyMode;
     this.supportsTransactedBatch = SupportsTransactedBatch(runtime.ChannelDispatcher);
 }
Exemplo n.º 37
0
 internal InstanceBehavior(DispatchRuntime dispatch, ImmutableDispatchRuntime immutableRuntime)
 {
     _provider = dispatch.InstanceProvider;
     _instanceContextProvider = dispatch.InstanceContextProvider;
 }
Exemplo n.º 38
0
 private void InitializeIsolationLevel(DispatchRuntime dispatch)
 {
     this.isolation = dispatch.ChannelDispatcher.TransactionIsolationLevel;
 }
Exemplo n.º 39
0
 internal ConcurrencyBehavior(DispatchRuntime runtime)
 {
     _concurrencyMode       = runtime.ConcurrencyMode;
     _enforceOrderedReceive = runtime.EnsureOrderedDispatch;
 }
 internal PerSessionInstanceContextProvider(DispatchRuntime dispatchRuntime) : base(dispatchRuntime)
 {
 }
Exemplo n.º 41
0
 internal PerCallInstanceContextProvider(DispatchRuntime dispatchRuntime) : base(dispatchRuntime)
 {
 }
        public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
        {
            var dispatchDictionary = new Dictionary <string, string>();

            foreach (OperationDescription operationDescription in contractDescription.Operations)
            {
                //DispatchBodyElementAttribute dispatchElement = operationDescription.Behaviors.Find<DispatchBodyElementAttribute>();
                dispatchDictionary.Add(operationDescription.Name, operationDescription.Name);
            }
            dispatchRuntime.OperationSelector =
                new DispatchByBodyElementOperationSelector(dispatchDictionary, dispatchRuntime.UnhandledDispatchOperation.Name);
        }
 internal InstanceContextProviderBase(DispatchRuntime dispatchRuntime)
 {
     _dispatchRuntime = dispatchRuntime;
 }
Exemplo n.º 44
0
 void Init(DispatchRuntime runtime, IChannel replyOrInput)
 {
     dispatch_runtime = runtime;
     reply_or_input   = replyOrInput;
 }
Exemplo n.º 45
0
        void PopulateDispatchOperation(DispatchRuntime db, OperationDescription od)
        {
            string reqA = null, resA = null;

            foreach (MessageDescription m in od.Messages)
            {
                if (m.IsRequest)
                {
                    reqA = m.Action;
                }
                else
                {
                    resA = m.Action;
                }
            }
            DispatchOperation o =
                od.IsOneWay ?
                new DispatchOperation(db, od.Name, reqA) :
                new DispatchOperation(db, od.Name, reqA, resA);

            o.IsTerminating = od.IsTerminating;
            bool no_serialized_reply = od.IsOneWay;

            foreach (MessageDescription md in od.Messages)
            {
                if (md.IsRequest &&
                    md.Body.Parts.Count == 1 &&
                    md.Body.Parts [0].Type == typeof(Message))
                {
                    o.DeserializeRequest = false;
                }
                if (!md.IsRequest &&
                    md.Body.ReturnValue != null)
                {
                    if (md.Body.ReturnValue.Type == typeof(Message))
                    {
                        o.SerializeReply = false;
                    }
                    else if (md.Body.ReturnValue.Type == typeof(void))
                    {
                        no_serialized_reply = true;
                    }
                }
            }

            foreach (var fd in od.Faults)
            {
                o.FaultContractInfos.Add(new FaultContractInfo(fd.Action, fd.DetailType));
            }

            // Setup Invoker
            o.Invoker = new DefaultOperationInvoker(od);

            // Setup Formater
            // FIXME: this seems to be null at initializing, and should be set after applying all behaviors.
            // I leave this as is to not regress and it's cosmetic compatibility to fix.
            // FIXME: pass correct isRpc, isEncoded
            o.Formatter = new OperationFormatter(od, false, false);

            if (o.Action == "*" && (o.IsOneWay || o.ReplyAction == "*"))
            {
                //Signature : Message  (Message)
                //	    : void  (Message)
                //FIXME: void (IChannel)
                if (!o.DeserializeRequest && (!o.SerializeReply || no_serialized_reply))                 // what is this double-ish check for?
                {
                    db.UnhandledDispatchOperation = o;
                }
            }

            db.Operations.Add(o);
        }
Exemplo n.º 46
0
 private void ApplyRoleProvider(DispatchRuntime dispatch)
 {
     this.roleProvider = dispatch.RoleProvider;
 }
Exemplo n.º 47
0
        void PopulateDispatchOperation(DispatchRuntime db, OperationDescription od)
        {
            string reqA = null, resA = null;

            foreach (MessageDescription m in od.Messages)
            {
                if (m.Direction == MessageDirection.Input)
                {
                    reqA = m.Action;
                }
                else
                {
                    resA = m.Action;
                }
            }
            DispatchOperation o =
                od.IsOneWay ?
                new DispatchOperation(db, od.Name, reqA) :
                new DispatchOperation(db, od.Name, reqA, resA);
            bool no_serialized_reply = od.IsOneWay;

            foreach (MessageDescription md in od.Messages)
            {
                if (md.Direction == MessageDirection.Input &&
                    md.Body.Parts.Count == 1 &&
                    md.Body.Parts [0].Type == typeof(Message))
                {
                    o.DeserializeRequest = false;
                }
                if (md.Direction == MessageDirection.Output &&
                    md.Body.ReturnValue != null)
                {
                    if (md.Body.ReturnValue.Type == typeof(Message))
                    {
                        o.SerializeReply = false;
                    }
                    else if (md.Body.ReturnValue.Type == typeof(void))
                    {
                        no_serialized_reply = true;
                    }
                }
            }

            // Setup Invoker
            o.Invoker = new DefaultOperationInvoker(od);

            // Setup Formater
            o.Formatter = BaseMessagesFormatter.Create(od);

            if (o.Action == "*" && (o.IsOneWay || o.ReplyAction == "*"))
            {
                //Signature : Message  (Message)
                //	    : void  (Message)
                //FIXME: void (IChannel)
                if (!o.DeserializeRequest && (!o.SerializeReply || no_serialized_reply))                 // what is this double-ish check for?
                {
                    db.UnhandledDispatchOperation = o;
                }
            }

            db.Operations.Add(o);
        }
Exemplo n.º 48
0
        public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
        {
            // We iterate over the operation descriptions in the contract and
            // record the QName of the request body child element and corresponding operation name
            // to the dictionary to be used for dispatch
            Dictionary <XmlQualifiedName, string> dispatchDictionary = new Dictionary <XmlQualifiedName, string>();

            foreach (OperationDescription operationDescription in contractDescription.Operations)
            {
                XmlQualifiedName qname =
                    new XmlQualifiedName(operationDescription.Messages[0].Body.WrapperName, operationDescription.Messages[0].Body.WrapperNamespace);

                dispatchDictionary.Add(qname, operationDescription.Name);
            }

            // Lastly, we create and assign and instance of our operation selector that
            // gets the dispatch dictionary we've just created.
            dispatchRuntime.OperationSelector =
                new DispatchByBodyElementOperationSelector(dispatchDictionary);
        }
Exemplo n.º 49
0
 public DispatchOperation(DispatchRuntime parent, string name, string action, string replyAction) : this(parent, name, action)
 {
     this.replyAction = replyAction;
     this.isOneWay    = false;
 }
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
 {
     // We iterate over the operation descriptions in the contract and
     // try to locate an DispatchBodyElementAttribute behaviors on each
     // operation. If found, we add the operation, keyed by QName of the body element
     // that selects which calls shall be dispatched to this operation to a
     // dictionary.
     //Logger.Write("starting ApplyDispatchBehavior");
     try
     {
         Dictionary <XmlQualifiedName, string> dispatchDictionary = new Dictionary <XmlQualifiedName, string>();
         foreach (OperationDescription operationDescription in contractDescription.Operations)
         {
             DispatchBodyElementAttribute dispatchBodyElement =
                 operationDescription.Behaviors.Find <DispatchBodyElementAttribute>();
             if (dispatchBodyElement != null)
             {
                 dispatchDictionary.Add(dispatchBodyElement.QName, operationDescription.Name);
                 //Logger.Write(string.Format("method {0} added", operationDescription.Name));
             }
         }
         // Lastly, we create and assign and instance of our operation selector that
         // gets the dispatch dictionary we've just created.
         dispatchRuntime.OperationSelector =
             new DispatchByBodyElementOperationSelector(
                 dispatchDictionary,
                 dispatchRuntime.UnhandledDispatchOperation.Name);
     }
     catch (Exception ex)
     {
         Logger.Write(ex.Message);
         throw;
     }
 }
 private static AuthorizationBehavior CreateAuthorizationBehavior(DispatchRuntime dispatch)
 {
     return(new AuthorizationBehavior {
         externalAuthorizationPolicies = dispatch.ExternalAuthorizationPolicies, serviceAuthorizationManager = dispatch.ServiceAuthorizationManager, auditLogLocation = dispatch.SecurityAuditLogLocation, suppressAuditFailure = dispatch.SuppressAuditFailure, serviceAuthorizationAuditLevel = dispatch.ServiceAuthorizationAuditLevel
     });
 }
        internal static IInstanceContextProvider GetProviderForMode(InstanceContextMode instanceMode, DispatchRuntime runtime)
        {
            switch (instanceMode)
            {
            case InstanceContextMode.PerSession:
                return(new PerSessionInstanceContextProvider(runtime));

            default:
                throw new PlatformNotSupportedException();
            }
        }
Exemplo n.º 53
0
 internal DispatchBehaviorCollection(DispatchRuntime outer)
     : base(outer.ThisLock)
 {
     _outer = outer;
 }
Exemplo n.º 54
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
 {
 }
 internal InstanceManager(DispatchRuntime runtime)
 {
     dispatch_runtime = runtime;
 }
Exemplo n.º 56
0
 internal ThreadBehavior(DispatchRuntime dispatch)
 {
     _context = dispatch.SynchronizationContext;
 }
        internal static IInstanceContextProvider GetProviderForMode(InstanceContextMode instanceMode, DispatchRuntime runtime)
        {
            switch (instanceMode)
            {
            case InstanceContextMode.PerCall:
                return(new PerCallInstanceContextProvider(runtime));

            case InstanceContextMode.PerSession:
                return(new PerSessionInstanceContextProvider(runtime));

            case InstanceContextMode.Single:
                return(new SingletonInstanceContextProvider(runtime));

            default:
                DiagnosticUtility.FailFast("InstanceContextProviderBase.GetProviderForMode: default");
                return(null);
            }
        }
Exemplo n.º 58
0
 internal InstanceBehavior(DispatchRuntime runtime)
 {
     dispatch_runtime = runtime;
 }
Exemplo n.º 59
0
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
 {
     if (dispatch.ClientRuntime != null)
     {
         dispatch.ClientRuntime.OperationSelector = new MethodInfoOperationSelector(description, MessageDirection.Output);
     }
 }
Exemplo n.º 60
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.InstanceProvider = this;
 }