當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。