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


C# MessageHeaders.GetHeader方法代码示例

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


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

示例1: GetDataSignature

 /// <summary>
 /// Gets the data signature in the given message header collection
 /// </summary>
 /// <param name="headers">Message headers</param>
 /// <returns>Data signature or Guid.Empty</returns>
 public static Guid GetDataSignature(MessageHeaders headers)
 {
     Guid dataSignature = Guid.Empty;
     int headerIndex = headers.FindHeader(Header.Name, Header.Namespace);
     if (headerIndex != -1)
     {
         dataSignature = headers.GetHeader<Guid>(headerIndex);
     }
     return dataSignature;
 }
开发者ID:qwert789,项目名称:codegallery,代码行数:15,代码来源:DataSignature.cs

示例2: InspectHeaders

 public void InspectHeaders(MessageHeaders messageHeaders)
 {
     try
     {
         var timestamp = messageHeaders.GetHeader<DateTime?>("time", SoapExtensionsNamespace);
         _notifyCallback(timestamp);
     }
     catch (Exception)
     {
         _notifyCallback(null);
     }
 }
开发者ID:Garwin4j,项目名称:BrightstarDB,代码行数:12,代码来源:ReplyMessageInspector.cs

示例3: SetDataContract

        /// <summary>
        /// Set wellknown headers into the CallContext Thread slot
        /// </summary>
        /// <param name="headers">List of all message headers</param>
        /// <param name="actor">Role (actor) of the headers. Note this is also the name of the assembly, where must be declared all CallContext Headers.</param>
        public static void SetDataContract(MessageHeaders headers, string actor)
        {
            if (string.IsNullOrEmpty(actor))
            {
                try
                {
                    // wellknown header LogicalWorkflowContext
                    LogicalWorkflowContext lwc = headers.GetHeader<LogicalWorkflowContext>("LogicalWorkflowContext", "RKiss.WorkflowRemoting", "WorkflowRemoting");
                    if(lwc == null)
                        throw new NullReferenceException("Deserializer failed for header 'LogicalWorkflowContext'");

                    // set data into the Thread slot
                    CallContext.SetData("LogicalWorkflowContext", lwc);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                }
            }
            else
            {
                bool bDoneForLWC = false;
                for (int ii = 0; ii < headers.Count; ii++)
                {
                    string typeName = string.Concat(headers[ii].Namespace, ".", headers[ii].Name, ",", headers[ii].Actor);
                    if (!bDoneForLWC && typeName == "RKiss.WorkflowRemoting.LogicalWorkflowContext,WorkflowRemoting")
                    {
                        object lwc = headers.GetHeader<LogicalWorkflowContext>(ii);
                        if (lwc == null)
                            throw new NullReferenceException("Deserializer failed for header 'LogicalWorkflowContext'");

                        // set data into the Thread slot
                        CallContext.SetData("LogicalWorkflowContext", lwc);

                        // next header
                        bDoneForLWC = true;
                        continue;
                    }
                    else if (!string.IsNullOrEmpty(headers[ii].Actor) && string.Concat(actor, ",").Contains(string.Concat(headers[ii].Actor, ",")))
                    {
                        try
                        {
                            Type type = Type.GetType(typeName);
                            if (type == null)
                                throw new TypeLoadException(typeName);

                            // deserializer
                            DataContractSerializer dcs = new DataContractSerializer(type, headers[ii].Name, headers[ii].Namespace);
                            object data = dcs.ReadObject(headers.GetReaderAtHeader(ii), true);

                            if (data == null)
                                throw new NullReferenceException(string.Format("Deserializer failed for header '{0}'", headers[ii].Name));

                            // set data into the Thread slot
                            CallContext.SetData(headers[ii].Name, data);
                        }
                        catch (Exception ex)
                        {
                            Trace.WriteLine(ex);
                        }
                    }
                }
            }
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:69,代码来源:indigo.cs

示例4: GetHeaderNullSerializer2

		public void GetHeaderNullSerializer2 ()
		{
			MessageHeaders headers = new MessageHeaders (MessageVersion.Default);
			string ns = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
			headers.Add (MessageHeader.CreateHeader ("Action", ns, "urn:foo"));
			headers.GetHeader<string> ("Action", ns, (XmlObjectSerializer) null);
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:MessageHeadersTest.cs


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