Esempio n. 1
0
        public void InitializeRuntime1()
        {
            using (ServiceHost host = new ServiceHost(typeof(MyService), new Uri("http://localhost:" + NetworkHelpers.FindFreePort()))) {
                host.AddServiceEndpoint(typeof(IMyContract), new BasicHttpBinding(), "e1");

                Assert.AreEqual(0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");
                try {
                    host.Open();

                    Assert.AreEqual(2, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");

                    ChannelDispatcher cd = (ChannelDispatcher)host.ChannelDispatchers [1];
                    Assert.AreEqual(1, cd.Endpoints.Count, "Endpoints.Count");
                    Assert.AreEqual("ServiceMetadataBehaviorHttpGetBinding", cd.BindingName, "BindingName");
                    Assert.AreEqual(host, cd.Host, "Host");
                    //Assert.AreEqual (false, cd.IsTransactedAccept, "IsTransactedAccept");
                    //Assert.AreEqual (false, cd.IsTransactedReceive, "IsTransactedReceive");

                    EndpointDispatcher ed = cd.Endpoints [0];
                    Assert.AreEqual(typeof(EndpointAddressMessageFilter), ed.AddressFilter.GetType(), "AddressFilter");
                    Assert.AreEqual(cd, ed.ChannelDispatcher, "ChannelDispatcher");
                    Assert.AreEqual(typeof(MatchAllMessageFilter), ed.ContractFilter.GetType(), "ContractFilter");
                    Assert.AreEqual("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName");
                    Assert.AreEqual("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace");
                    Assert.AreEqual(0, ed.FilterPriority, "FilterPriority");

                    EndpointAddress ea = ed.EndpointAddress;
                    // TODO

                    DispatchRuntime dr = ed.DispatchRuntime;
                    // TODO
                } finally {
                    host.Close();
                }
            }
        }
Esempio n. 2
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     foreach (DispatchOperation op in dispatchRuntime.Operations)
     {
         op.ParameterInspectors.Add(new ParameterValidatorBehavior());
     }
 }
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription contract, ServiceEndpoint endpoint, DispatchRuntime runtime)
 {
     Debug.WriteLine(string.Format("Applying dispatch ExceptionMarshallingBehavior to contract {0}", contract.ContractType.FullName));
     this.ApplyDispatchBehavior(runtime.ChannelDispatcher);
 }
 /// <summary>
 /// The apply dispatch behavior.
 /// </summary>
 /// <param name="contractDescription">
 /// The contract description.
 /// </param>
 /// <param name="endpoint">
 /// The endpoint.
 /// </param>
 /// <param name="dispatchRuntime">
 /// The dispatch runtime.
 /// </param>
 public void ApplyDispatchBehavior(
     ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     ReplaceDataContractSerializerOperationBehaviors(contractDescription, this._on);
 }
 		public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 		{
 			foreach (OperationDescription operationDescription in contractDescription.Operations)
 			{
 				if (!operationDescription.Behaviors.Contains(typeof(OperationLoggerBehavior)))
 				{
 					operationDescription.Behaviors.Add(new OperationLoggerBehavior());
 				}
 			}
 		}
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     _behavior.ApplyDispatchBehavior(contractDescription, endpoint, dispatchRuntime);
 }
Esempio n. 7
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     Console.WriteLine("Contract - ApplyDispatchBehavior " + _host.ChannelDispatchers.Count);
     _state.CurrentStage += ", IContractBehavior.ApplyDispatchBehavior";
 }
Esempio n. 8
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint,
                                   DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.InstanceProvider = instanceProvider;
     dispatchRuntime.InstanceContextInitializers.Add(new DIInstanceContextInitializer());
 }
Esempio n. 9
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     foreach (KnownTypeAssignAttribute assign in Attribute.GetCustomAttributes(contractDescription.ContractType, typeof(KnownTypeAssignAttribute)))
     {
         OperationDescription operation = contractDescription.Operations.Find(assign.OperationName);
         if (operation != null)
         {
             foreach (Type type in assign.KnownTypes)
             {
                 operation.KnownTypes.Add(type);
             }
         }
     }
 }
 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));
             }
         }
     }
 }
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     ConfigureDataContractSurrogate(endpoint.Contract);
 }
Esempio n. 12
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     foreach (var dop in dispatchRuntime.Operations)
     {
         dop.CallContextInitializers.Add(new CultureReceiver(messageHeadInfo));
     }
 }
 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);
     }
 }
Esempio n. 14
0
        internal static void ApplyDispatchBehavior(ThreadPoolSynchronizer synchronizer, uint poolSize, Type type, string poolName, DispatchRuntime dispatch)
        {
            Debug.Assert(dispatch.SynchronizationContext == null);
            int maxConcurrentCalls = 16;

            if (dispatch.ChannelDispatcher.ServiceThrottle != null)
            {
                maxConcurrentCalls = dispatch.ChannelDispatcher.ServiceThrottle.MaxConcurrentCalls;
            }
            if (maxConcurrentCalls < poolSize)
            {
                throw new InvalidOperationException("The throttle should allow at least as many concurrent calls as the pool size");
            }

            if (HasSynchronizer(type))
            {
                Debug.Assert(GetSynchronizer(type) == synchronizer);
            }

            if (HasSynchronizer(type) == false)
            {
                m_Synchronizers[type] = synchronizer;
            }
            dispatch.SynchronizationContext = synchronizer;
        }
Esempio n. 15
0
 public WfInstanceContextProvider(DispatchRuntime dr)
 {
     _DR = dr;
 }
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
 {
     dispatch.OperationSelector = new OperationSelector(this.messageHandler);
     if (dispatch.ClientRuntime != null)
     {
         dispatch.ClientRuntime.OperationSelector = new OperationSelectorBehavior.MethodInfoOperationSelector(description, MessageDirection.Output);
     }
 }
Esempio n. 17
0
        private void ApplyInstancing(ServiceDescription description, ServiceHostBase serviceHostBase)
        {
            Type            serviceType = description.ServiceType;
            InstanceContext singleton   = null;

            for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++)
            {
                if (serviceHostBase.ChannelDispatchers[i] is ChannelDispatcher channelDispatcher)
                {
                    foreach (EndpointDispatcher endpointDispatcher in channelDispatcher.Endpoints)
                    {
                        if (endpointDispatcher.IsSystemEndpoint)
                        {
                            continue;
                        }
                        DispatchRuntime dispatch = endpointDispatcher.DispatchRuntime;
                        if (dispatch.InstanceProvider == null)
                        {
                            if (_instanceProvider == null)
                            {
                                if (serviceType == null && _wellKnownSingleton == null)
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.InstanceSettingsMustHaveTypeOrWellKnownObject0));
                                }

                                if (_instanceMode != InstanceContextMode.Single && _wellKnownSingleton != null)
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxWellKnownNonSingleton0));
                                }
                            }
                            else
                            {
                                dispatch.InstanceProvider = _instanceProvider;
                            }
                        }
                        dispatch.Type = serviceType;
                        dispatch.InstanceContextProvider = InstanceContextProviderBase.GetProviderForMode(_instanceMode, dispatch);

                        if ((_instanceMode == InstanceContextMode.Single) &&
                            (dispatch.SingletonInstanceContext == null))
                        {
                            if (singleton == null)
                            {
                                if (_wellKnownSingleton != null)
                                {
                                    singleton = new InstanceContext(serviceHostBase, _wellKnownSingleton, true, false);
                                }
                                else if (_hiddenSingleton != null)
                                {
                                    singleton = new InstanceContext(serviceHostBase, _hiddenSingleton, false, false);
                                }
                                else
                                {
                                    singleton = new InstanceContext(serviceHostBase, false);
                                }

                                singleton.AutoClose = false;
                            }
                            dispatch.SingletonInstanceContext = singleton;
                        }
                    }
                }
            }
        }
Esempio n. 18
0
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
 {
     dispatch.OperationSelector = new OperationSelector();
 }
 public void ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
 {
     return;//this.contractDescription = description;
 }
Esempio n. 20
0
 /// <summary>Implements a modification or extension of the service 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>
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.InstanceProvider = new DomainDataServiceInstanceProvider();
 }
Esempio n. 21
0
 public void ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
 {
     m_BehaviorFlags.DisptacherContractBehaviorFlag = true;
 }
Esempio n. 22
0
        static void BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch)
        {
            if (!(((proxy == null) != (dispatch == null))))
            {
                throw Fx.AssertAndThrowFatal("DispatcherBuilder.BindOperations: ((proxy == null) != (dispatch == null))");
            }

            MessageDirection local = (proxy == null) ? MessageDirection.Input : MessageDirection.Output;

            for (int i = 0; i < contract.Operations.Count; i++)
            {
                OperationDescription operation = contract.Operations[i];
                MessageDescription   first     = operation.Messages[0];

                if (first.Direction != local)
                {
                    if (proxy == null)
                    {
                        proxy = dispatch.CallbackClientRuntime;
                    }

                    ClientOperation proxyOperation = proxy.Operations[operation.Name];
                    Fx.Assert(proxyOperation != null, "");

                    for (int j = 0; j < operation.Behaviors.Count; j++)
                    {
                        IOperationBehavior behavior = operation.Behaviors[j];
                        behavior.ApplyClientBehavior(operation, proxyOperation);
                    }
                }
                else
                {
                    if (dispatch == null)
                    {
                        dispatch = proxy.CallbackDispatchRuntime;
                    }

                    DispatchOperation dispatchOperation = null;
                    if (dispatch.Operations.Contains(operation.Name))
                    {
                        dispatchOperation = dispatch.Operations[operation.Name];
                    }
                    if (dispatchOperation == null && dispatch.UnhandledDispatchOperation != null && dispatch.UnhandledDispatchOperation.Name == operation.Name)
                    {
                        dispatchOperation = dispatch.UnhandledDispatchOperation;
                    }

                    if (dispatchOperation != null)
                    {
                        for (int j = 0; j < operation.Behaviors.Count; j++)
                        {
                            IOperationBehavior behavior = operation.Behaviors[j];
                            behavior.ApplyDispatchBehavior(operation, dispatchOperation);
                        }
                    }
                }
            }
        }
 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();
 }
Esempio n. 24
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     foreach (EndpointDispatcher dis in dispatchRuntime.ChannelDispatcher.Endpoints)
     {
         dis.DispatchRuntime.MessageInspectors.Add(new ServiceInterpector());
     }
 }
 /// <summary>
 /// The apply dispatch behavior.
 /// </summary>
 /// <param name="contractDescription">
 /// The contract description.
 /// </param>
 /// <param name="endpoint">
 /// The endpoint.
 /// </param>
 /// <param name="dispatchRuntime">
 /// The dispatch runtime.
 /// </param>
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.InstanceProvider = this;
 }
        /// <inheritdoc />
        public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
        {
#if NETFRAMEWORK
            TelemetryEndpointBehavior.ApplyDispatchBehaviorToEndpoint(dispatchRuntime.EndpointDispatcher);
#endif
        }
 /// <summary>
 /// The apply dispatch behavior.
 /// </summary>
 /// <param name="contractDescription">
 /// The contract description.
 /// </param>
 /// <param name="endpoint">
 /// The endpoint.
 /// </param>
 /// <param name="dispatchRuntime">
 /// The dispatch runtime.
 /// </param>
 void IContractBehavior.ApplyDispatchBehavior(
     ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     CyclicReferencesAwareContractBehavior.ReplaceDataContractSerializerOperationBehaviors(
         contractDescription, this.On);
 }
Esempio n. 28
0
 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));
     }
 }
Esempio n. 29
0
 public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
     dispatchRuntime.MessageInspectors.Add(new ServerMessageInspector());
 }
Esempio n. 30
0
 void IContractBehavior.ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime)
 {
 }