public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            Fx.Assert(operationDescription != null, "OperationDescription cannot be null!");
            Fx.Assert(dispatchOperation != null, "DispatchOperation cannot be null!");

            if (dispatchOperation.Formatter == null)
            {
                return;
            }

            this.formatter = dispatchOperation.Formatter;
            this.faultFormatter = dispatchOperation.FaultFormatter;
            if (this.receives != null)
            {
                foreach (Receive receive in this.receives)
                {
                    receive.SetFormatter(this.formatter, this.faultFormatter, dispatchOperation.IncludeExceptionDetailInFaults);
                }
            }

            // Remove operation formatter from dispatch runtime
            dispatchOperation.Formatter = null;
            dispatchOperation.DeserializeRequest = false;
            dispatchOperation.SerializeReply = false;
        }
        public void ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
        {
            if (description == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");
            }
            if (dispatch == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dispatch");
            }
            if (dispatch.Parent == null
                || dispatch.Parent.ChannelDispatcher == null
                || dispatch.Parent.ChannelDispatcher.Host == null
                || dispatch.Parent.ChannelDispatcher.Host.Description == null
                || dispatch.Parent.ChannelDispatcher.Host.Description.Behaviors == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.DispatchOperationInInvalidState)));
            }

            WorkflowRuntimeBehavior workflowRuntimeBehavior = dispatch.Parent.ChannelDispatcher.Host.Description.Behaviors.Find<WorkflowRuntimeBehavior>();

            if (workflowRuntimeBehavior == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.GetString(SR2.NoWorkflowRuntimeBehavior)));
            }

            dispatch.Invoker = new WorkflowOperationInvoker(description, this, workflowRuntimeBehavior.WorkflowRuntime, dispatch.Parent);
        }
        internal DispatchOperationRuntime(DispatchOperation operation, ImmutableDispatchRuntime parent)
        {
            if (operation == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
            }
            if (parent == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
            }
            if (operation.Invoker == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.RuntimeRequiresInvoker0));
            }

            _disposeParameters = ((operation.AutoDisposeParameters) && (!operation.HasNoDisposableParameters));
            _parent = parent;
            _inspectors = EmptyArray<IParameterInspector>.ToArray(operation.ParameterInspectors);
            _faultFormatter = operation.FaultFormatter;
            _deserializeRequest = operation.DeserializeRequest;
            _serializeReply = operation.SerializeReply;
            _formatter = operation.Formatter;
            _invoker = operation.Invoker;

            _isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled;
            _action = operation.Action;
            _name = operation.Name;
            _replyAction = operation.ReplyAction;
            _isOneWay = operation.IsOneWay;

            if (_formatter == null && (_deserializeRequest || _serializeReply))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.DispatchRuntimeRequiresFormatter0, _name)));
            }
        }
        public void ApplyDispatchBehavior(OperationDescription operationDescription, 
            DispatchOperation dispatchOperation)
        {
            var behavior =
                operationDescription.DeclaringContract.FindBehavior
                    <WebAuthenticationConfigurationBehavior,
                     WebAuthenticationConfigurationAttribute>(b => b.BaseBehavior) ??
                dispatchOperation.Parent.ChannelDispatcher.Host.Description.FindBehavior
                    <WebAuthenticationConfigurationBehavior,
                     WebAuthenticationConfigurationAttribute>(b => b.BaseBehavior);

            if (behavior == null)
                throw new ConfigurationErrorsException(
                    "OperationAuthenticationConfigurationBehavior not applied to contract or service. This behavior is required to configure operation authentication.");

            var authorizationBehavior =
                operationDescription.DeclaringContract.FindBehavior
                    <WebAuthorizationConfigurationBehavior,
                    WebAuthorizationConfigurationAttribute>(b => b.BaseBehavior);

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

            dispatchOperation.Invoker = new OperationAuthenticationInvoker(
                dispatchOperation.Invoker,
                behavior.ThrowIfNull().AuthenticationHandler,
                behavior.UsernamePasswordValidatorType,
                behavior.RequireSecureTransport,
                behavior.Source,
                authorizationPolicy);
        }
 public ProfilingOperationInvoker(DispatchOperation dispatchOperation, string outputPath)
 {
     _operation = dispatchOperation;
     _original = dispatchOperation.Invoker;
     IsSynchronous = _original.IsSynchronous;
     OutputPath = outputPath;
 }
        public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            var behavior =
                operationDescription.DeclaringContract.Behaviors.Find
                    <WebDispatchFormatterConfigurationBehavior>();

            if (behavior == null)
                behavior = dispatchOperation.Parent.ChannelDispatcher.Host.Description.Behaviors.Find
                        <WebDispatchFormatterConfigurationBehavior>();

            if (behavior == null)
            {
                var configurationAttribute =
                    operationDescription.DeclaringContract.GetAttribute<WebDispatchFormatterConfigurationAttribute>();

                if (configurationAttribute == null)
                    configurationAttribute = dispatchOperation.Parent.ChannelDispatcher.Host.Description.
                        GetAttribute<WebDispatchFormatterConfigurationAttribute>();

                string defaultMimeType = null;

                if (configurationAttribute != null)
                    defaultMimeType = configurationAttribute.DefaultMimeType;

                var mimeTypeAttributes =
                    operationDescription.DeclaringContract.GetAttributes<WebDispatchFormatterMimeTypeAttribute>();

                if (mimeTypeAttributes == null || mimeTypeAttributes.Count == 0)
                    mimeTypeAttributes = dispatchOperation.Parent.ChannelDispatcher.Host.Description.
                        GetAttributes<WebDispatchFormatterMimeTypeAttribute>();

                var formatters = new Dictionary<string, Type>();

                if (mimeTypeAttributes != null && mimeTypeAttributes.Count > 0)
                {

                    foreach (var mimeTypeAttribute in mimeTypeAttributes)
                        foreach (var mimeType in mimeTypeAttribute.MimeTypes)
                        {
                            if (defaultMimeType == null) defaultMimeType = mimeType;
                            formatters.Add(mimeType, mimeTypeAttribute.Type);
                        }
                }

                if (formatters.Count > 0)
                    behavior = new WebDispatchFormatterConfigurationBehavior(
                        formatters, defaultMimeType);
            }

            if (behavior == null)
                throw new ConfigurationErrorsException(
                    "WebDispatchFormatterConfigurationBehavior or WebDispatchFormatterMimeTypeAttribute's not applied to contract or service. This behavior or attributes are required to configure web dispatch formatting.");

            dispatchOperation.Formatter =
                new WebDispatchFormatter(
                    behavior.FormatterFactory,
                    operationDescription,
                    _direction != WebDispatchFormatter.FormatterDirection.Both ? dispatchOperation.Formatter : null,
                    _direction);
        }
 public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
 {
     dispatchOperation.CallContextInitializers.Add(new MyCallContextInitializer());
     dispatchOperation.Formatter = new MyDispatchMessageFormatter(dispatchOperation.Formatter);
     dispatchOperation.Invoker = new MyOperationInvoker(dispatchOperation.Invoker);
     dispatchOperation.ParameterInspectors.Add(new MyParameterInspector(true));
 }
 public ComPlusThreadInitializer(ContractDescription contract, DispatchOperation operation, ServiceInfo info)
 {
     this.info = info;
     this.iid = contract.ContractType.GUID;
     if (info.CheckRoles)
     {
         string[] serviceRoleMembers = null;
         string[] contractRoleMembers = null;
         string[] operationRoleMembers = null;
         serviceRoleMembers = info.ComponentRoleMembers;
         foreach (ContractInfo info2 in this.info.Contracts)
         {
             if (!(info2.IID == this.iid))
             {
                 continue;
             }
             contractRoleMembers = info2.InterfaceRoleMembers;
             foreach (System.ServiceModel.ComIntegration.OperationInfo info3 in info2.Operations)
             {
                 if (info3.Name == operation.Name)
                 {
                     operationRoleMembers = info3.MethodRoleMembers;
                     break;
                 }
             }
             if (operationRoleMembers == null)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("ComOperationNotFound", new object[] { contract.Name, operation.Name })));
             }
             break;
         }
         this.comAuth = new ComPlusAuthorization(serviceRoleMembers, contractRoleMembers, operationRoleMembers);
     }
 }
 public void ApplyDispatchBehavior(OperationDescription description, DispatchOperation runtime)
 {
     if (_runtime == runtime.Parent)
     {
         runtime.Formatter = new BinaryFormatterAdapter(description.Name, description.SyncMethod.GetParameters(), runtime.Formatter);
     }
 }
 void IOperationBehavior.ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
 {
     if (dispatch == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dispatch");
     }
     if (description == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");
     }
     if (description.SyncMethod != null)
     {
         if (description.BeginMethod != null)
         {
             OperationBehaviorAttribute attribute = description.Behaviors.Find<OperationBehaviorAttribute>();
             if ((attribute != null) && attribute.PreferAsyncInvocation)
             {
                 dispatch.Invoker = new AsyncMethodInvoker(description.BeginMethod, description.EndMethod);
             }
             else
             {
                 dispatch.Invoker = new SyncMethodInvoker(description.SyncMethod);
             }
         }
         else
         {
             dispatch.Invoker = new SyncMethodInvoker(description.SyncMethod);
         }
     }
     else if (description.BeginMethod != null)
     {
         dispatch.Invoker = new AsyncMethodInvoker(description.BeginMethod, description.EndMethod);
     }
 }
 public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
 {
     var previousInvoker = dispatchOperation.Invoker;
     var methodName = operationDescription.Name;
     var newInvoker = new CachingOperationInvoker(methodName, previousInvoker, ExpirationTime, RegionName);
     dispatchOperation.Invoker = newInvoker;
 }
        /// <summary>
        /// Apply the dispatch behavior by requiring
        /// the use of the NetDataContractSerializer.
        /// </summary>
        /// <param name="description">Operation description.</param>
        /// <param name="dispatch">Dispatch operation object.</param>
        public void ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
        {
            description.Behaviors.Remove<DataContractSerializerOperationBehavior>();

            IOperationBehavior ndcob = new NetDataContractOperationBehavior(description);
            ndcob.ApplyDispatchBehavior(description, dispatch);
        }
Exemple #13
0
        public void ApplyDispatchBehavior(OperationDescription operationDescription,
                                          System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
        {
            var SerializerBehavior = operationDescription.Behaviors.Find <DataContractSerializerOperationBehavior>();

            dispatchOperation.Formatter = new JsonFormatter(dispatchOperation.Formatter, operationDescription);
        }
        private static void CreateHttpGetChannelDispatcher(ServiceHostBase host, Uri listenUri, MetadataSet metadata)
        {
            //创建Binding
            TextMessageEncodingBindingElement messageEncodingElement = new TextMessageEncodingBindingElement() { MessageVersion = MessageVersion.None };
            HttpTransportBindingElement transportElement = new HttpTransportBindingElement();
            Utility.SetPropertyValue(transportElement, "Method", "GET");
            Binding binding = new CustomBinding(messageEncodingElement, transportElement);

            //创建ChannelListener
            IChannelListener listener = binding.BuildChannelListener<IReplyChannel>(listenUri, string.Empty, ListenUriMode.Explicit, new BindingParameterCollection());
            ChannelDispatcher dispatcher = new ChannelDispatcher(listener, "ServiceMetadataBehaviorHttpGetBinding", binding) { MessageVersion = binding.MessageVersion };

            //创建EndpointDispatcher
            EndpointDispatcher endpoint = new EndpointDispatcher(new EndpointAddress(listenUri), "IHttpGetMetadata", "http://www.artech.com/");

            //创建DispatchOperation,并设置DispatchMessageFormatter和OperationInvoker
            DispatchOperation operation = new DispatchOperation(endpoint.DispatchRuntime, "Get", "*", "*");
            operation.Formatter = Utility.CreateInstance<IDispatchMessageFormatter>(MessageOperationFormatterType, Type.EmptyTypes, new object[0]);
            MethodInfo method = typeof(IHttpGetMetadata).GetMethod("Get");
            operation.Invoker = Utility.CreateInstance<IOperationInvoker>(SyncMethodInvokerType, new Type[] { typeof(MethodInfo) }, new object[] { method });
            endpoint.DispatchRuntime.Operations.Add(operation);

            //设置SingletonInstanceContext和InstanceContextProvider
            MetadataProvisionService serviceInstance = new MetadataProvisionService(metadata);
            endpoint.DispatchRuntime.SingletonInstanceContext = new InstanceContext(host, serviceInstance);
            endpoint.DispatchRuntime.InstanceContextProvider = Utility.CreateInstance<IInstanceContextProvider>(SingletonInstanceContextProviderType, new Type[] { typeof(DispatchRuntime) }, new object[] { endpoint.DispatchRuntime });
            dispatcher.Endpoints.Add(endpoint);

            //设置ContractFilter和AddressFilter
            endpoint.ContractFilter = new MatchAllMessageFilter();
            endpoint.AddressFilter = new MatchAllMessageFilter();

            host.ChannelDispatchers.Add(dispatcher);
        }
 public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
 {
     ServiceHostBase host = dispatchOperation.Parent.ChannelDispatcher.Host;
     if (!(host is WorkflowServiceHost))
     {
         throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.WorkflowBehaviorWithNonWorkflowHost(typeof(ControlOperationBehavior).Name)));
     }
     ServiceEndpoint endpoint = null;
     foreach (ServiceEndpoint endpoint2 in host.Description.Endpoints)
     {
         if (endpoint2.Id == dispatchOperation.Parent.EndpointDispatcher.Id)
         {
             endpoint = endpoint2;
             break;
         }
     }
     if (this.isWrappedMode)
     {
         CorrelationKeyCalculator correlationKeyCalculator = null;
         if (endpoint != null)
         {
             CorrelationQueryBehavior behavior = endpoint.Behaviors.Find<CorrelationQueryBehavior>();
             if (behavior != null)
             {
                 correlationKeyCalculator = behavior.GetKeyCalculator();
             }
         }
         dispatchOperation.Invoker = new ControlOperationInvoker(operationDescription, endpoint, correlationKeyCalculator, dispatchOperation.Invoker, host);
     }
     else
     {
         dispatchOperation.Invoker = new ControlOperationInvoker(operationDescription, endpoint, null, host);
     }
 }
 public void ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
 {
     var dataContractSerializerOperationBehavior =
         description.Behaviors.Find<DataContractSerializerOperationBehavior>();
     dataContractSerializerOperationBehavior.DataContractResolver =
         new ProxyDataContractResolver();
 }
        // ────────────────────────── IOperationBehavior Members ──────────────────────────
        public void ApplyDispatchBehavior(OperationDescription operationDescription,
        DispatchOperation dispatchOperation)
        {
            var behavior =
              operationDescription.DeclaringContract.FindBehavior
              <OAuthAuthenticationConfigurationBehavior,
              OAuthAuthenticationConfigurationAttribute>(b => b.BaseBehavior);

              if (behavior == null)
            behavior = dispatchOperation.Parent.ChannelDispatcher.Host.Description.FindBehavior
                <OAuthAuthenticationConfigurationBehavior,
                OAuthAuthenticationConfigurationAttribute>(b => b.BaseBehavior);

              if (behavior == null)
            throw new ConfigurationErrorsException(
            "OperationAuthenticationConfigurationBehavior not applied to contract or service. This behavior is required to configure operation authentication.");

              var scopeToUse = string.IsNullOrWhiteSpace(this.Scope) ? behavior.Scope : this.Scope;

              dispatchOperation.Invoker = new OperationOAuthAuthenticationInvoker(
              dispatchOperation.Invoker,
              behavior.AuthenticationHandler,
              behavior.RequireSecureTransport,
               scopeToUse,
               AllowAnonymous);
        }
Exemple #18
0
 public void ApplyDispatchBehavior(OperationDescription description,
     DispatchOperation dispatch)
 {
     IOperationBehavior innerBehavior =
       new ReferencePreservingDataContractSerializerOperationBehavior(description);
     innerBehavior.ApplyDispatchBehavior(description, dispatch);
 }
        public void ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
        {
            if (dispatch.Invoker is ExceptionHandlingOperationInvoker)
                return;

            dispatch.Invoker = new ExceptionHandlingOperationInvoker(dispatch.Invoker);
        }
        internal static IDispatchMessageFormatter GetDispatcherFormatterFromRuntime(OperationDescription operationDescription)
        {
            System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation = new System.ServiceModel.Dispatcher.DispatchOperation(DummyDispatchRuntime, operationDescription.Name, operationDescription.Messages[0].Action);
            IOperationBehavior operationBehavior = new DataContractSerializerOperationBehavior(operationDescription);
            operationBehavior.ApplyDispatchBehavior(operationDescription, dispatchOperation);

            return dispatchOperation.Formatter;
        }
Exemple #21
0
        public void ApplyDispatchBehavior(OperationDescription operationDescription,

                                          System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
        {
            // Change the IOperationInvoker for this operation.

            dispatchOperation.Invoker = new STAOperationInvoker(dispatchOperation.Invoker);
        }
 void IOperationBehavior.ApplyDispatchBehavior(OperationDescription operationDescription, 
     DispatchOperation dispatchOperation)
 { 
     ZipCodeInspector zipCodeInspector = new ZipCodeInspector(); 
     
     dispatchOperation.ParameterInspectors.Add(zipCodeInspector); 
 
 }  // remaining methods empty 
 public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
 {
     if (_catchException)
     {
         dispatchOperation.Invoker = new CatchExceptionOperationInvoker(dispatchOperation.Invoker,
             operationDescription.Name);
     }
 }
Exemple #24
0
        internal static IDispatchMessageFormatter GetDispatcherFormatterFromRuntime(OperationDescription operationDescription)
        {
            System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation = new System.ServiceModel.Dispatcher.DispatchOperation(DummyDispatchRuntime, operationDescription.Name, operationDescription.Messages[0].Action);
            IOperationBehavior operationBehavior = new DataContractSerializerOperationBehavior(operationDescription);

            operationBehavior.ApplyDispatchBehavior(operationDescription, dispatchOperation);

            return(dispatchOperation.Formatter);
        }
		void IOperationBehavior.ApplyDispatchBehavior (
			OperationDescription description,
			DispatchOperation dispatch)
		{
			if (description == null)
				throw new ArgumentNullException ("description");
			if (dispatch == null)
				throw new ArgumentNullException ("dispatch");
			dispatch.Formatter = new XmlMessagesFormatter (description, format);
		}
        public void ApplyDispatchBehavior(OperationDescription operationDescription,
                                          DispatchOperation dispatchOperation)
        {
            if (dispatchOperation == null)
                throw new ArgumentNullException("dispatchOperation");

            // Wrap the operation invoker inside our custom operation 
            // invoker which does the persisting work.
            dispatchOperation.Invoker = new OperationInvoker(dispatchOperation.Invoker);
        }
Exemple #27
0
        /// <summary>
        /// Implements the <c>IEndpointBehavior.ApplyDispatchBehavior</c> method to support modification or extension of the client across an endpoint.
        /// </summary>
        /// <param name="endpoint">The endpoint that exposes the contract.</param>
        /// <param name="endpointDispatcher">The endpoint dispatcher to which the behavior is applied.</param>
        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            //Create endpoint capabilities descriptor
            var capabilities = new AmfEndpointCapabilities
            {
                MessagingVersion = 1,
                ExceptionDetailInFaults = endpointDispatcher.ChannelDispatcher.IncludeExceptionDetailInFaults
            };

            //Create endpoint context
            var endpointContext = new AmfEndpointContext(endpoint);

            //Create AMF message filter
            endpointDispatcher.ContractFilter = new AmfMessageFilter();

            //Create operation selector that will resolve messages' data contracts and route service methods for AMF requests.
            endpointDispatcher.DispatchRuntime.OperationSelector = new AmfDispatchOperationSelector(endpointContext);

            //Create message inspector that will dereference reply messages' data contracts
            endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new AmfMessageInspector(endpointContext));

            //Create error handler
            endpointDispatcher.ChannelDispatcher.ErrorHandlers.Add(new AmfErrorHandler(capabilities));

            //Apply regular AMF operation behavior
            foreach (var descriptor in endpoint.Contract.Operations)
            {
                if (descriptor.Behaviors.OfType<AmfOperationBehavior>().FirstOrDefault() != null) continue;

                descriptor.Behaviors.Add(new AmfOperationBehavior());
            }

            //Command operation
            var commandOperation = new DispatchOperation(endpointDispatcher.DispatchRuntime,
                                                         AmfOperationKind.Command,
                                                         AmfOperationKind.Command,
                                                         null)
            {
                Invoker = new AmfCommandInvoker(capabilities),
                Formatter = new AmfCommandFormatter(),
            };
            endpointDispatcher.DispatchRuntime.Operations.Add(commandOperation);

            //Fault operation
            var faultOperation = new DispatchOperation(endpointDispatcher.DispatchRuntime,
                                                         AmfOperationKind.Fault,
                                                         AmfOperationKind.Fault,
                                                         null)
            {
                Invoker = new AmfFaultInvoker(capabilities),
                Formatter = new AmfGenericOperationFormatter()
            };
            endpointDispatcher.DispatchRuntime.Operations.Add(faultOperation);
        }
 public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
 {
     dispatchOperation.SerializeReply        = true;
     dispatchOperation.DeserializeRequest    = true;
     var dataContractFormatAttribute = operationDescription.SyncMethod.GetCustomAttributes(typeof(DataContractFormatAttribute), true).FirstOrDefault() as DataContractFormatAttribute;
     if (null == dataContractFormatAttribute)
     {
         dataContractFormatAttribute = new DataContractFormatAttribute();
     }
     var dataContractSerializerOperationBehavior = operationDescription.Behaviors.Find<DataContractSerializerOperationBehavior>();
     dispatchOperation.Formatter = new CompressionMessageFormatter(this.Algorithm, operationDescription, dataContractFormatAttribute, dataContractSerializerOperationBehavior);
 }
 private void AddParameterInspector(DispatchOperation dispatchOperation,
                                    OperationDescription operationDescription)
 {
     var parameterInspector = new ParameterInspector(operationDescription)
                              {
                                  LogAction = LogAction,
                                  OnError = OnError,
                                  IsParameterLoggingEnabled =
                                      parameterName => IsParameterLoggingEnabled(dispatchOperation, parameterName)
                              };
     dispatchOperation.ParameterInspectors.Add(parameterInspector);
 }
		public void ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)
		{
			DispatchOperation operation = new DispatchOperation(endpointDispatcher.DispatchRuntime, "*", "*", "*")
			{
				Formatter = new WfWebScriptMetadataFomatter(),
				Invoker = new WfWebScriptMetadataInvoker(endpoint, endpointDispatcher.DispatchRuntime.UnhandledDispatchOperation)
			};

			endpointDispatcher.DispatchRuntime.UnhandledDispatchOperation = operation;
			//AddMetadataEndpoint(endpoint, endpointDispatcher, true);
			//AddMetadataEndpoint(endpoint, endpointDispatcher, false);
		}
        } // do nothing

        public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            if (!AspNetEnvironment.Current.AspNetCompatibilityEnabled)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.CacheProfileOnlySupportedInAspNetCompatibilityMode));
            }
            
            if (operationDescription.Behaviors.Find<WebGetAttribute>() == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.CacheProfileAttributeOnlyWithGet));
            }
            dispatchOperation.ParameterInspectors.Add(new CachingParameterInspector(this.cacheProfileName));
        }
        public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            ServiceHostBase serviceHost = dispatchOperation.Parent.ChannelDispatcher.Host;
            if (!(serviceHost is WorkflowServiceHost))
            {
                throw FxTrace.Exception.AsError(
                   new InvalidOperationException(SR.WorkflowBehaviorWithNonWorkflowHost(typeof(ControlOperationBehavior).Name)));
            }

            ServiceEndpoint endpoint = null;
            foreach (ServiceEndpoint endpointToMatch in serviceHost.Description.Endpoints)
            {
                if (endpointToMatch.Id == dispatchOperation.Parent.EndpointDispatcher.Id)
                {
                    endpoint = endpointToMatch;
                    break;
                }
            }

            if (this.isWrappedMode)
            {
                CorrelationKeyCalculator keyCalculator = null;

                if (endpoint != null)
                {
                    CorrelationQueryBehavior endpointQueryBehavior = endpoint.Behaviors.Find<CorrelationQueryBehavior>();

                    if (endpointQueryBehavior != null)
                    {
                        keyCalculator = endpointQueryBehavior.GetKeyCalculator();
                    }
                }

                //This will be the case for infrastructure endpoints like Compensation/Interop OCS endpoints.
                dispatchOperation.Invoker = new ControlOperationInvoker(
                    operationDescription,
                    endpoint,
                    keyCalculator,
                    dispatchOperation.Invoker,
                    serviceHost);
            }
            else
            {
                //This will be for IWorkflowInstanceManagement endpoint operation.
                dispatchOperation.Invoker = new ControlOperationInvoker(
                    operationDescription,
                    endpoint,
                    null,
                    serviceHost);
            }
        }
        public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            if (operationDescription == null)
            {
                throw FxTrace.Exception.ArgumentNull("operationDescription");
            }
            if (dispatchOperation == null)
            {
                throw FxTrace.Exception.ArgumentNull("dispatchOperation");
            }
            if (dispatchOperation.Parent == null
                || dispatchOperation.Parent.ChannelDispatcher == null
                || dispatchOperation.Parent.ChannelDispatcher.Host == null
                || dispatchOperation.Parent.ChannelDispatcher.Host.Description == null
                || dispatchOperation.Parent.ChannelDispatcher.Host.Description.Behaviors == null)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.DispatchOperationInInvalidState));
            }

            ServiceHostBase serviceHost = dispatchOperation.Parent.ChannelDispatcher.Host;
            if (!(serviceHost is WorkflowServiceHost))
            {
                throw FxTrace.Exception.AsError(
                   new InvalidOperationException(SR.WorkflowBehaviorWithNonWorkflowHost(typeof(WorkflowOperationBehavior).Name)));
            }

            CorrelationKeyCalculator correlationKeyCalculator = null;

            ServiceEndpoint endpoint = null;
            foreach (ServiceEndpoint endpointToMatch in serviceHost.Description.Endpoints)
            {
                if (endpointToMatch.Id == dispatchOperation.Parent.EndpointDispatcher.Id)
                {
                    endpoint = endpointToMatch;
                    break;
                }
            }

            if (endpoint != null)
            {
                CorrelationQueryBehavior queryBehavior = endpoint.Behaviors.Find<CorrelationQueryBehavior>();

                if (queryBehavior != null)
                {
                    correlationKeyCalculator = queryBehavior.GetKeyCalculator();
                }
            }

            dispatchOperation.Invoker = new WorkflowOperationInvoker(operationDescription,
                endpoint, correlationKeyCalculator, this, serviceHost, dispatchOperation.Invoker);
        }
Exemple #34
0
 void IOperationBehavior.ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
 {
     CyclicReferencesAwareContractBehavior.ReplaceDataContractSerializerOperationBehavior(operationDescription, On);
 }
 void IOperationBehavior.ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
 {
     if (IsAuthenticationEnabled)
     {
         dispatchOperation.ParameterInspectors.Add(this);
     }
 }
 public void ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
 {
 }
Exemple #37
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);
        }
        internal DispatchOperationRuntime(DispatchOperation operation, ImmutableDispatchRuntime parent)
        {
            if (operation == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation");
            }
            if (parent == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
            }
            if (operation.Invoker == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.RuntimeRequiresInvoker0)));
            }

            this.disposeParameters       = ((operation.AutoDisposeParameters) && (!operation.HasNoDisposableParameters));
            this.parent                  = parent;
            this.callContextInitializers = EmptyArray <ICallContextInitializer> .ToArray(operation.CallContextInitializers);

            this.inspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors);

            this.faultFormatter     = operation.FaultFormatter;
            this.impersonation      = operation.Impersonation;
            this.deserializeRequest = operation.DeserializeRequest;
            this.serializeReply     = operation.SerializeReply;
            this.formatter          = operation.Formatter;
            this.invoker            = operation.Invoker;

            try
            {
                this.isSynchronous = operation.Invoker.IsSynchronous;
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
            }
            this.isTerminating = operation.IsTerminating;
            this.isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled;
            this.action = operation.Action;
            this.name   = operation.Name;
            this.releaseInstanceAfterCall  = operation.ReleaseInstanceAfterCall;
            this.releaseInstanceBeforeCall = operation.ReleaseInstanceBeforeCall;
            this.replyAction                       = operation.ReplyAction;
            this.isOneWay                          = operation.IsOneWay;
            this.transactionAutoComplete           = operation.TransactionAutoComplete;
            this.transactionRequired               = operation.TransactionRequired;
            this.receiveContextAcknowledgementMode = operation.ReceiveContextAcknowledgementMode;
            this.bufferedReceiveEnabled            = operation.BufferedReceiveEnabled;
            this.isInsideTransactedReceiveScope    = operation.IsInsideTransactedReceiveScope;

            if (this.formatter == null && (deserializeRequest || serializeReply))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.DispatchRuntimeRequiresFormatter0, this.name)));
            }

            if ((operation.Parent.InstanceProvider == null) && (operation.Parent.Type != null))
            {
                SyncMethodInvoker sync = this.invoker as SyncMethodInvoker;
                if (sync != null)
                {
                    this.ValidateInstanceType(operation.Parent.Type, sync.Method);
                }

                AsyncMethodInvoker async = this.invoker as AsyncMethodInvoker;
                if (async != null)
                {
                    this.ValidateInstanceType(operation.Parent.Type, async.BeginMethod);
                    this.ValidateInstanceType(operation.Parent.Type, async.EndMethod);
                }

                TaskMethodInvoker task = this.invoker as TaskMethodInvoker;
                if (task != null)
                {
                    this.ValidateInstanceType(operation.Parent.Type, task.TaskMethod);
                }
            }
        }
Exemple #39
0
        public void ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
        {
            IOperationInvoker invoke = dispatchOperation.Invoker;

            dispatchOperation.Invoker = CreateInvoker(invoke);
        }
 public void ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
 {
     //add an invoker that checks for the claims before executing the next invoker in the chain
     dispatchOperation.Invoker = new CheckClaimInvoker(dispatchOperation.Invoker, Checklist.ToArray());
 }
    public void ApplyDispatchBehavior(OperationDescription description, System.ServiceModel.Dispatcher.DispatchOperation dispatch)
    {
        DataContractSerializerOperationBehavior dataContractSerializerOperationBehavior = description.Behaviors.Find <DataContractSerializerOperationBehavior>();

        dataContractSerializerOperationBehavior.DataContractResolver = new ProxyDataContractResolver();
    }
Exemple #42
0
        public void ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
        {
            IOperationInvoker invoker = dispatchOperation.Invoker;

            dispatchOperation.Invoker = new WCFSerialCachingInvoker(invoker);
        }
Exemple #43
0
 public void ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
 {
     dispatchOperation.Formatter = new CompressionMessageFormatter(dispatchOperation.Formatter, dispatchOperation.ReplyAction, _useCompression);
 }
Exemple #44
0
    public void ApplyDispatchBehavior(OperationDescription description, System.ServiceModel.Dispatcher.DispatchOperation dispatch)
    {
        IOperationBehavior innerBehavior = new ReferencePreservingDataContractSerializerOperationBehavior(description);

        innerBehavior.ApplyDispatchBehavior(description, dispatch);
    }
Exemple #45
0
 internal DispatchRuntime(EndpointDispatcher dispatcher, ClientRuntime callbackClientRuntime)
 {
     UnhandledDispatchOperation = new DispatchOperation(
         this, "*", "*", "*");
 }
Exemple #46
0
 public void ApplyDispatchBehavior(OperationDescription description,
                                   System.ServiceModel.Dispatcher.DispatchOperation dispatch)
 {
     ReplaceDataContractSerializerOperationBehavior(description);
 }