• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Description.OperationDescription类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FillOperation

        static void FillOperation(IWmiInstance operation, OperationDescription operationDescription)
        {
            operation.SetProperty(AdministrationStrings.Name, operationDescription.Name);
            operation.SetProperty(AdministrationStrings.Action, FixWildcardAction(operationDescription.Messages[0].Action));
            if (operationDescription.Messages.Count > 1)
            {
                operation.SetProperty(AdministrationStrings.ReplyAction, FixWildcardAction(operationDescription.Messages[1].Action));
            }
            operation.SetProperty(AdministrationStrings.IsOneWay, operationDescription.IsOneWay);
            operation.SetProperty(AdministrationStrings.IsInitiating, operationDescription.IsInitiating);
            operation.SetProperty(AdministrationStrings.IsTerminating, operationDescription.IsTerminating);
            operation.SetProperty(AdministrationStrings.AsyncPattern, null != operationDescription.BeginMethod);
            if (null != operationDescription.SyncMethod)
            {
                if (null != operationDescription.SyncMethod.ReturnType)
                {
                    operation.SetProperty(AdministrationStrings.ReturnType, operationDescription.SyncMethod.ReturnType.Name);
                }
                operation.SetProperty(AdministrationStrings.MethodSignature, operationDescription.SyncMethod.ToString());
                ParameterInfo[] parameterInfo = operationDescription.SyncMethod.GetParameters();
                string[] parameterTypes = new string[parameterInfo.Length];
                for (int i = 0; i < parameterInfo.Length; i++)
                {
                    parameterTypes[i] = parameterInfo[i].ParameterType.ToString();
                }
                operation.SetProperty(AdministrationStrings.ParameterTypes, parameterTypes);
            }
            operation.SetProperty(AdministrationStrings.IsCallback, operationDescription.Messages[0].Direction == MessageDirection.Output);

            FillBehaviorsInfo(operation, operationDescription.Behaviors);

        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:32,代码来源:ContractInstanceProvider.cs


示例2: DefaultJsonSerializerOperationBehavior

 public DefaultJsonSerializerOperationBehavior(OperationDescription operation, bool isCompress, 
     SerializeContentTypes contentType)
     : base(operation)
 {
     m_IsCompress = isCompress;
     m_ContentType = contentType;
 }
开发者ID:JackFong,项目名称:GenericWcfServiceHostAndClient,代码行数:7,代码来源:DefaultJsonSerializerOperationBehavior.cs


示例3: XmlSerializerOperationFormatter

 public XmlSerializerOperationFormatter(OperationDescription description, XmlSerializerFormatAttribute xmlSerializerFormatAttribute,
     MessageInfo requestMessageInfo, MessageInfo replyMessageInfo) :
     base(description, xmlSerializerFormatAttribute.Style == OperationFormatStyle.Rpc, false/*isEncoded*/)
 {
     _requestMessageInfo = requestMessageInfo;
     _replyMessageInfo = replyMessageInfo;
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:7,代码来源:XmlSerializerOperationFormatter.cs


示例4: GetRequestClientFormatter

        protected override IClientMessageFormatter GetRequestClientFormatter(OperationDescription operationDescription, ServiceEndpoint endpoint)
        {
            if (operationDescription.Behaviors.Find<WebGetAttribute>() != null)
            {
                // no change for GET operations
                return base.GetRequestClientFormatter(operationDescription, endpoint);
            }
            else
            {
                WebInvokeAttribute wia = operationDescription.Behaviors.Find<WebInvokeAttribute>();
                if (wia != null)
                {
                    if (wia.Method == "HEAD")
                    {
                        // essentially a GET operation
                        return base.GetRequestClientFormatter(operationDescription, endpoint);
                    }
                }
            }

            if (operationDescription.Messages[0].Body.Parts.Count == 0)
            {
                // nothing in the body, still use the default
                return base.GetRequestClientFormatter(operationDescription, endpoint);
            }

            return new NewtonsoftJsonClientFormatter(operationDescription, endpoint);
        }
开发者ID:GusLab,项目名称:WCFSamples,代码行数:28,代码来源:NewtonsoftJsonBehavior.cs


示例5: ApplyDispatchBehavior

 public void ApplyDispatchBehavior(OperationDescription description,
     System.ServiceModel.Dispatcher.DispatchOperation dispatch)
 {
     IOperationBehavior innerBehavior =
       new ReferencePreservingDataContractSerializerOperationBehavior(description);
     innerBehavior.ApplyDispatchBehavior(description, dispatch);
 }
开发者ID:Whylex,项目名称:ikit-mita-materials,代码行数:7,代码来源:ReferencePreservingDataContractFormatAttribute.cs


示例6: ValidateOperation

        private void ValidateOperation(OperationDescription operation)
        {
            if (operation.Messages.Count > 1)
            {
                if (operation.Messages[1].Body.Parts.Count > 0)
                {
                    throw new InvalidOperationException("Operations cannot have out/ref parameters.");
                }
            }

            WebMessageBodyStyle bodyStyle = this.GetBodyStyle(operation);
            int inputParameterCount = operation.Messages[0].Body.Parts.Count;
            if (!this.IsGetOperation(operation))
            {
                var wrappedRequest = bodyStyle == WebMessageBodyStyle.Wrapped || bodyStyle == WebMessageBodyStyle.WrappedRequest;
                if (inputParameterCount == 1 && wrappedRequest)
                {
                    throw new InvalidOperationException("Wrapped body style for single parameters not implemented in this behavior.");
                }
            }

            var wrappedResponse = bodyStyle == WebMessageBodyStyle.Wrapped || bodyStyle == WebMessageBodyStyle.WrappedResponse;
            var isVoidReturn = operation.Messages.Count == 1 || operation.Messages[1].Body.ReturnValue.Type == typeof(void);
            if (!isVoidReturn && wrappedResponse)
            {
                throw new InvalidOperationException("Wrapped response not implemented in this behavior.");
            }
        }
开发者ID:devworker55,项目名称:Mammatus,代码行数:28,代码来源:NewtonsoftJsonBehavior.cs


示例7: AddBindingParameters

        public void AddBindingParameters(OperationDescription description, BindingParameterCollection parameters)
        {
            //see if ChunkingBindingParameter already exists
            ChunkingBindingParameter param =
                parameters.Find<ChunkingBindingParameter>();
            if (param == null)
            {
                param = new ChunkingBindingParameter();
                parameters.Add(param);
            }

            if ((appliesTo & ChunkingAppliesTo.InMessage)
                          == ChunkingAppliesTo.InMessage)
            {
                //add input message's action to ChunkingBindingParameter
                param.AddAction(description.Messages[0].Action);
            }
            if (!description.IsOneWay &&
                ((appliesTo & ChunkingAppliesTo.OutMessage)
                            == ChunkingAppliesTo.OutMessage))
            {
                //add output message's action to ChunkingBindingParameter
                param.AddAction(description.Messages[1].Action);
            }
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:25,代码来源:ChunkingBehavior.cs


示例8: ApplyClientBehavior

 public void ApplyClientBehavior(OperationDescription description, ClientOperation proxy)
 {
     var dataContractSerializerOperationBehavior =
         description.Behaviors.Find<DataContractSerializerOperationBehavior>();
     dataContractSerializerOperationBehavior.DataContractResolver =
         new ProxyDataContractResolver();
 }
开发者ID:ntrhieu89,项目名称:ChineseCharacterTrainer,代码行数:7,代码来源:ApplyDataContractResolverAttribute.cs


示例9: InferMessageDescription

 internal override void InferMessageDescription(OperationDescription operation, object owner, MessageDirection direction)
 {
     ContractInferenceHelper.CheckForDisposableParameters(operation, this.InternalDeclaredMessageType);
     string overridingAction = null;
     SerializerOption dataContractSerializer = SerializerOption.DataContractSerializer;
     Receive receive = owner as Receive;
     if (receive != null)
     {
         overridingAction = receive.Action;
         dataContractSerializer = receive.SerializerOption;
     }
     else
     {
         ReceiveReply reply = owner as ReceiveReply;
         overridingAction = reply.Action;
         dataContractSerializer = reply.Request.SerializerOption;
     }
     if (direction == MessageDirection.Input)
     {
         ContractInferenceHelper.AddInputMessage(operation, overridingAction, this.InternalDeclaredMessageType, dataContractSerializer);
     }
     else
     {
         ContractInferenceHelper.AddOutputMessage(operation, overridingAction, this.InternalDeclaredMessageType, dataContractSerializer);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:ReceiveMessageContent.cs


示例10: ApplyDispatchBehavior

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


示例11: ZipCodeInspector

 void IOperationBehavior.ApplyClientBehavior(OperationDescription operationDescription, 
     ClientOperation clientOperation) 
 {
     ZipCodeInspector zipCodeInspector = new ZipCodeInspector(); 
     
     clientOperation.ParameterInspectors.Add(zipCodeInspector); 
 }
开发者ID:cleancodenz,项目名称:ServiceBus,代码行数:7,代码来源:ZipCodeValidation.cs


示例12: Validate

 public void Validate(OperationDescription operationDescription)
 {
     if (operationDescription.Messages.Count < 2 || operationDescription.Messages[1].Body.ReturnValue.Type != typeof(double))
     {
         throw new InvalidOperationException("This behavior can only be applied on operation which returns double");
     }
 }
开发者ID:solondon,项目名称:VisualStudio2013andNETCookbookCode,代码行数:7,代码来源:Program.cs


示例13: TryGetSurrogateBehavior

 private static void TryGetSurrogateBehavior(OperationDescription operationDescription, ref IOperationBehavior original, ref IOperationBehavior surrogate)
 {
     if (!IsUntypedMessage(operationDescription.Messages[0]) &&
         operationDescription.Messages[0].Body.Parts.Count != 0)
     {
         var webGetAttribute = operationDescription.Behaviors.Find<WebGetAttribute>();
         if (webGetAttribute != null)
         {
             original = webGetAttribute;
             surrogate = new WebInvokeAttribute {
                  BodyStyle = webGetAttribute.BodyStyle,
                  Method = "NONE",
                  RequestFormat = webGetAttribute.RequestFormat,
                  ResponseFormat = webGetAttribute.ResponseFormat,
                  UriTemplate = webGetAttribute.UriTemplate };
         }
         else
         {
             var webInvokeAttribute = operationDescription.Behaviors.Find<WebInvokeAttribute>();
             if (webInvokeAttribute != null && webInvokeAttribute.Method == "GET")
             {
                 original = webInvokeAttribute;
                 surrogate = new WebInvokeAttribute {
                     BodyStyle = webInvokeAttribute.BodyStyle,
                     Method = "NONE",
                     RequestFormat = webInvokeAttribute.RequestFormat,
                     ResponseFormat = webInvokeAttribute.ResponseFormat,
                     UriTemplate = webInvokeAttribute.UriTemplate };
             }
         }
     }
 }
开发者ID:richet,项目名称:WcfRestContrib,代码行数:32,代码来源:WebHttpBehavior.cs


示例14: 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


示例15:

 void IOperationBehavior.ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
 {
     if (IsAuthenticationEnabled)
     {
         dispatchOperation.ParameterInspectors.Add(this);
     }
 }
开发者ID:ergin-a1,项目名称:REST_API_Prototype_NET35,代码行数:7,代码来源:APISecurityAttribute.cs


示例16: AddPingToContractDescription

        /// <summary>
        /// Add the Ping method to the existing contract
        /// </summary>
        private void AddPingToContractDescription(ContractDescription contractDescription)
        {
            OperationDescription pingOperationDescription = new OperationDescription(PingOperationName, contractDescription);

            MessageDescription inputMessageDescription = new MessageDescription(
                GetAction(contractDescription, PingOperationName),
                MessageDirection.Input);

            MessageDescription outputMessageDescription = new MessageDescription(
                GetAction(contractDescription, PingResponse),
                MessageDirection.Output);

            MessagePartDescription returnValue = new MessagePartDescription("PingResult", contractDescription.Namespace);

            returnValue.Type = typeof(DateTime);
            outputMessageDescription.Body.ReturnValue = returnValue;

            inputMessageDescription.Body.WrapperName = PingOperationName;
            inputMessageDescription.Body.WrapperNamespace = contractDescription.Namespace;
            outputMessageDescription.Body.WrapperName = PingResponse;
            outputMessageDescription.Body.WrapperNamespace = contractDescription.Namespace;

            pingOperationDescription.Messages.Add(inputMessageDescription);
            pingOperationDescription.Messages.Add(outputMessageDescription);

            pingOperationDescription.Behaviors.Add(new DataContractSerializerOperationBehavior(pingOperationDescription));
            pingOperationDescription.Behaviors.Add(new PingOperationBehavior());

            contractDescription.Operations.Add(pingOperationDescription);
        }
开发者ID:serbrech,项目名称:WCFPing,代码行数:33,代码来源:PingEndpointBehavior.cs


示例17: ApplyClientBehavior

        public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
        {
            Console.WriteLine("{0}: ", clientOperation.Name);
            IClientMessageFormatter formatter = clientOperation.Formatter;
            Console.WriteLine("\t{0}", formatter.GetType().Name);

            if (formatter.GetType().Name != "CompositeClientFormatter")
            {
            return;
            }

            object innerFormatter = this.GetField(formatter, "request");
            Console.WriteLine("\t\t{0}", innerFormatter.GetType().Name);

            if (innerFormatter.GetType().Name == "UriTemplateClientFormatter")
            {
            innerFormatter = this.GetField(innerFormatter, "inner");
            Console.WriteLine("\t\t\t{0}", innerFormatter.GetType().Name);
            return;
            }

            if (innerFormatter.GetType().Name == "ContentTypeSettingClientMessageFormatter")
            {
            innerFormatter = this.GetField(innerFormatter, "innerFormatter");
            Console.WriteLine("\t\t\t{0}", innerFormatter.GetType().Name);

            if (innerFormatter.GetType().Name == "UriTemplateClientFormatter")
            {
                innerFormatter = this.GetField(innerFormatter, "inner");
                Console.WriteLine("\t\t\t\t{0}", innerFormatter.GetType().Name);
            }
            }
        }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:33,代码来源:DisplayClientMessageFormatter.cs


示例18: ProtoOperationBehavior

 /// <summary>
 /// Create a new ProtoOperationBehavior instance
 /// </summary>
 public ProtoOperationBehavior(OperationDescription operation)
     : base(operation)
 {
     #if !NO_RUNTIME
     model = RuntimeTypeModel.Default;
     #endif
 }
开发者ID:banksyhf,项目名称:Auxilium-2,代码行数:10,代码来源:ProtoOperationBehavior.cs


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Description.PolicyConversionContext类代码示例发布时间:2022-05-26
下一篇:
C# Description.MetadataSet类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap