当前位置: 首页>>代码示例>>C#>>正文


C# Dispatcher.DispatchOperation类代码示例

本文整理汇总了C#中System.ServiceModel.Dispatcher.DispatchOperation的典型用法代码示例。如果您正苦于以下问题:C# DispatchOperation类的具体用法?C# DispatchOperation怎么用?C# DispatchOperation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DispatchOperation类属于System.ServiceModel.Dispatcher命名空间,在下文中一共展示了DispatchOperation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyDispatchBehavior

        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);
        }
开发者ID:wildart,项目名称:WcfRestContrib,代码行数:32,代码来源:OperationAuthenticationBehavior.cs

示例2: ApplyDispatchBehavior

 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;
 }
开发者ID:Warrenn,项目名称:Carbon.MVC,代码行数:7,代码来源:CachingAttribute.cs

示例3: DispatchOperationRuntime

        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)));
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:35,代码来源:DispatchOperationRuntime.cs

示例4: CreateHttpGetChannelDispatcher

        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);
        }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:34,代码来源:ServiceMetadataBehaviorAttribute.cs

示例5: ApplyDispatchBehavior

        // ────────────────────────── 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);
        }
开发者ID:TWith2Sugars,项目名称:DOAP,代码行数:27,代码来源:OperationOAuthAuthenticationBehavior.cs

示例6: ApplyDispatchBehavior

        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;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:WorkflowFormatterBehavior.cs

示例7: if

 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);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:OperationInvokerBehavior.cs

示例8: ComPlusThreadInitializer

 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);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:ComPlusThreadInitializer.cs

示例9: ApplyDispatchBehavior

 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);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:ControlOperationBehavior.cs

示例10: ApplyDispatchBehavior

        public void ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
        {
            if (dispatch.Invoker is ExceptionHandlingOperationInvoker)
                return;

            dispatch.Invoker = new ExceptionHandlingOperationInvoker(dispatch.Invoker);
        }
开发者ID:alienwaredream,项目名称:toolsdotnet,代码行数:7,代码来源:ExceptionHandlingAttribute.cs

示例11: ApplyDispatchBehavior

        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);
        }
开发者ID:huoxudong125,项目名称:WcfRestContrib,代码行数:60,代码来源:WebDispatchFormatterBehavior.cs

示例12: ApplyDispatchBehavior

 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));
 }
开发者ID:huoxudong125,项目名称:WcfEverywhere,代码行数:7,代码来源:MyBehavior.cs

示例13: ProfilingOperationInvoker

 public ProfilingOperationInvoker(DispatchOperation dispatchOperation, string outputPath)
 {
     _operation = dispatchOperation;
     _original = dispatchOperation.Invoker;
     IsSynchronous = _original.IsSynchronous;
     OutputPath = outputPath;
 }
开发者ID:khoanguyen,项目名称:NugetDemo,代码行数:7,代码来源:ProfilingOperationInvoker.cs

示例14: ApplyDispatchBehavior

        /// <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);
        }
开发者ID:hardCTE,项目名称:Rafy,代码行数:13,代码来源:UseNetDataContractAttribute.cs

示例15: ApplyDispatchBehavior

 public void ApplyDispatchBehavior(OperationDescription description, DispatchOperation runtime)
 {
     if (_runtime == runtime.Parent)
     {
         runtime.Formatter = new BinaryFormatterAdapter(description.Name, description.SyncMethod.GetParameters(), runtime.Formatter);
     }
 }
开发者ID:peterluo0822,项目名称:wcf-1,代码行数:7,代码来源:BinaryFormatterBehavior.cs


注:本文中的System.ServiceModel.Dispatcher.DispatchOperation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。