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


C# MessageProperties.TryGetValue方法代码示例

本文整理汇总了C#中MessageProperties.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# MessageProperties.TryGetValue方法的具体用法?C# MessageProperties.TryGetValue怎么用?C# MessageProperties.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessageProperties的用法示例。


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

示例1: EchoHttpRequestMessageProperty

        public TestHttpRequestMessageProperty EchoHttpRequestMessageProperty()
        {
            object obj;
            MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
            if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
            {
                HttpRequestMessageProperty property = (HttpRequestMessageProperty)obj;
                if (property != null)
                {
                    TestHttpRequestMessageProperty testProperty = new TestHttpRequestMessageProperty();
                    testProperty.SuppressEntityBody = property.SuppressEntityBody;
                    testProperty.Method = property.Method;
                    testProperty.QueryString = property.QueryString;

                    WebHeaderCollection collection = property.Headers;
                    foreach (string s in collection.AllKeys)
                    {
                        string[] values = collection.GetValues(s);
                        testProperty.Headers.Add(s, String.Join(",", values));
                    }
                    return testProperty;
                }
            }

            return null;
        }
开发者ID:yxbdali,项目名称:wcf,代码行数:26,代码来源:WcfService.cs

示例2: ValidateMessagePropertyHeaders

        public Dictionary<string, string> ValidateMessagePropertyHeaders()
        {
            Dictionary<string, string> headerCollection = new Dictionary<string, string>();
            try
            {
                HttpRequestMessageProperty property;
                object obj;
                MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
                if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
                {
                    property = obj as HttpRequestMessageProperty;
                    WebHeaderCollection collection = property.Headers;

                    string[] headers = collection.AllKeys;
                    foreach (string s in headers)
                    {
                        string[] values = collection.GetValues(s);
                        headerCollection.Add(s, String.Join(",", values));
                    }
                }
                else
                {
                    headerCollection.Add("ERROR", "No HttpRequestMessageProperty was found!");
                }
            }
            catch (Exception ex)
            {
                headerCollection.Add("ERROR", string.Format("An exception was thrown: {0}", ex.Message));
            }

            return headerCollection;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:32,代码来源:WcfService.cs

示例3: MatchInternal

 bool MatchInternal(MessageProperties messageProperties)
 {
     object value;
     if (messageProperties.TryGetValue(EndpointNameKey, out value))
     {
         string messageEndpoint = value.ToString();
         return string.Equals(messageEndpoint, this.endpointName, StringComparison.Ordinal);
     }
     return false;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:EndpointNameMessageFilter.cs

示例4: TryGet

 public static bool TryGet(MessageProperties properties, out BufferedReceiveMessageProperty property)
 {
     object obj2 = null;
     if (properties.TryGetValue("BufferedReceiveMessageProperty", out obj2))
     {
         property = obj2 as BufferedReceiveMessageProperty;
     }
     else
     {
         property = null;
     }
     return (property != null);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:BufferedReceiveMessageProperty.cs

示例5: IsHttpPOSTMethod

 /// <summary>
 /// Checks if the HTTP method used is POST.
 /// </summary>
 /// <param name="properties">Properties for which the HTTP method is to be checked.</param>
 /// <returns><c>true</c> if the <paramref name="properties"/> specifies HTTP POST method.</returns>
 public static bool IsHttpPOSTMethod(MessageProperties properties)
 {
     object property;
     if (properties.TryGetValue(MessageUtility.HttpRequestName, out property))
     {
         HttpRequestMessageProperty httpMessageProperty = property as HttpRequestMessageProperty;
         if (httpMessageProperty != null && httpMessageProperty.Method.Equals(MessageUtility.HttpPostMethodName, StringComparison.OrdinalIgnoreCase))
         {
             return true;
         }
     }
     return false;
 }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:18,代码来源:MessageUtility.cs

示例6: TryGet

        public static bool TryGet(MessageProperties properties, out BufferedReceiveMessageProperty property)
        {
            Fx.Assert(properties != null, "The MessageProperties parameter is null");

            object value = null;
            if (properties.TryGetValue(PropertyName, out value))
            {
                property = value as BufferedReceiveMessageProperty;
            }
            else
            {
                property = null;
            }
            return property != null;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:15,代码来源:BufferedReceiveMessageProperty.cs

示例7: TryGet

        public static bool TryGet(MessageProperties properties, out ReceiveContext property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            property = null;
            object foundProperty;
            if (properties.TryGetValue(Name, out foundProperty))
            {
                property = (ReceiveContext)foundProperty;
                return true;
            }
            return false;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:16,代码来源:ReceiveContext.cs

示例8: TryGet

 public static bool TryGet(MessageProperties properties, out ContextMessageProperty contextMessageProperty)
 {
     if (properties == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
     }
     object obj2 = null;
     if (properties.TryGetValue("ContextMessageProperty", out obj2))
     {
         contextMessageProperty = obj2 as ContextMessageProperty;
     }
     else
     {
         contextMessageProperty = null;
     }
     return (contextMessageProperty != null);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:ContextMessageProperty.cs

示例9: TryGet

        public static bool TryGet(MessageProperties properties, out NetworkInterfaceMessageProperty property)
        {
            if (properties == null)
            {
                throw FxTrace.Exception.ArgumentNull("properties");
            }

            object value = null;
            if (properties.TryGetValue(PropertyName, out value))
            {
                property = value as NetworkInterfaceMessageProperty;
            }
            else
            {
                property = null;
            }
            return property != null;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:18,代码来源:NetworkInterfaceMessageProperty.cs

示例10: TryGet

        public static bool TryGet(MessageProperties properties, out ChannelBindingMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            property = null;
            object value;

            if (properties.TryGetValue(ChannelBindingMessageProperty.Name, out value))
            {
                property = value as ChannelBindingMessageProperty;
                return property != null;
            }

            return false;
        }
开发者ID:weshaggard,项目名称:wcf,代码行数:18,代码来源:ChannelBindingMessageProperty.cs

示例11: TryGet

        /// <summary>
        /// Gets the ImpersonateOnSerializingReplyMessageProperty property from MessageProperties.
        /// </summary>
        /// <param name="properties">The MessagePropeties object.</param>
        /// <param name="property">An output paramter to hold the ImpersonateOnSerializingReplyMessageProperty property.</param>
        /// <returns>True if the ImpersonateOnSerializingReplyMessageProperty property was found.</returns>
        public static bool TryGet(MessageProperties properties, out ImpersonateOnSerializingReplyMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            object value = null;
            if (properties.TryGetValue(PropertyName, out value))
            {
                property = value as ImpersonateOnSerializingReplyMessageProperty;
            }
            else
            {
                property = null;
            }

            return property != null;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:ImpersonateOnSerializingReplyMessageProperty.cs

示例12: MakeHttpPOSTMethod

        /// <summary>
        /// Changes a HTTP GET into a POST.
        /// </summary>
        /// <param name="properties">Properties for which the HTTP method is to be changed.</param>
        public static void MakeHttpPOSTMethod(MessageProperties properties)
        {
            object property;
            HttpRequestMessageProperty httpMessageProperty = null;

            if (properties.TryGetValue(MessageUtility.HttpRequestName, out property))
            {
                httpMessageProperty = property as HttpRequestMessageProperty;
            }

            if (httpMessageProperty == null)
            {
                httpMessageProperty = new HttpRequestMessageProperty();
                properties.Add(MessageUtility.HttpRequestName, httpMessageProperty);
            }

            httpMessageProperty.Method = MessageUtility.HttpPostMethodName;
            httpMessageProperty.SuppressEntityBody = false;
        }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:23,代码来源:MessageUtility.cs

示例13: UserGetAuthToken

        public MessageInspector_CustomHeaderAuthentication.ResultObject<string> UserGetAuthToken()
        {
            MessageInspector_CustomHeaderAuthentication.ResultObject<string> resultObject = null;

            try
            {
                HttpRequestMessageProperty property;
                object obj;
                MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
                if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
                {
                    property = obj as HttpRequestMessageProperty;
                    WebHeaderCollection collection = property.Headers;
                    string authValue = collection.Get(Enum.GetName(typeof(HttpRequestHeader), HttpRequestHeader.Authorization));

                    if (authValue == "Not Allowed")
                    {
                        resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject<string>.CreateFailureObject<string>();
                        resultObject.Result = resultObject.ResultMessage;
                    }
                    else if (authValue == "Allow")
                    {
                        resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject<string>.CreateSuccessObject<string>();
                        resultObject.Result = resultObject.ResultMessage;
                    }
                }
                else
                {
                    resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject<string>.CreateFailureObject<string>();
                    resultObject.Result = "ERROR";
                    resultObject.ResultMessage = "No HttpRequestMessageProperty was found on the incoming Message.";
                }
            }
            catch (Exception ex)
            {
                resultObject = MessageInspector_CustomHeaderAuthentication.ResultObject<string>.CreateFailureObject<string>();
                resultObject.Result = ex.ToString();
                resultObject.ResultMessage = ex.Message;
            }

            return resultObject;
        }
开发者ID:KKhurin,项目名称:wcf,代码行数:42,代码来源:WcfService.cs

示例14: TryGet

 public static bool TryGet(MessageProperties properties, out CorrelationDataMessageProperty property)
 {
     object obj2 = null;
     if (properties.TryGetValue("CorrelationDataMessageProperty", out obj2))
     {
         property = obj2 as CorrelationDataMessageProperty;
     }
     else
     {
         property = null;
     }
     return (property != null);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:CorrelationDataMessageProperty.cs

示例15: TryGetRequestReplyCorrelationInstanceKey

 bool TryGetRequestReplyCorrelationInstanceKey(MessageProperties messageProperties, out InstanceKey instanceKey)
 {
     instanceKey = null;
     CorrelationMessageProperty correlationMessageProperty;
     if (messageProperties.TryGetValue<CorrelationMessageProperty>(CorrelationMessageProperty.Name, out correlationMessageProperty))
     {
         foreach (InstanceKey key in correlationMessageProperty.TransientCorrelations)
         {
             InstanceValue value;
             if (key.Metadata.TryGetValue(WorkflowServiceNamespace.RequestReplyCorrelation, out value))
             {
                 instanceKey = key;
                 break;
             }
         }
     }
     return instanceKey != null;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:18,代码来源:InternalReceiveMessage.cs


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