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


C# MessageHeaders.FindHeader方法代码示例

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


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

示例1: ExtractActivityAndCorrelationId

        public static bool ExtractActivityAndCorrelationId(MessageHeaders headers, out Guid activityId, out Guid correlationId)
        {
            if (headers == null) throw new ArgumentNullException(nameof(headers));

            activityId = Guid.Empty;
            correlationId = Guid.Empty;

            try
            {
                var index = headers.FindHeader("ActivityId", "http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics");
                if (index >= 0)
                {
                    using (var reader = headers.GetReaderAtHeader(index))
                    {
                        correlationId = new Guid(reader.GetAttribute("CorrelationId", null));
                        activityId = reader.ReadElementContentAsGuid();
                        return true;
                    }
                }
            }
            catch
            {
                if (Debugger.IsAttached)
                {
                    throw;
                }
            }

            return false;
        }
开发者ID:Zywave,项目名称:SMLogging,代码行数:30,代码来源:MessageHelpers.cs

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

示例3: ReadFrom

 public static RequestTotalItemsCountEstimate ReadFrom(MessageHeaders messageHeaders)
 {
    int index = messageHeaders.FindHeader(ElementName, ManagementNamespaces.Namespace);
    if (index < 0)
    {
       return null;
    }         
    MessageHeaderInfo headerInfo = messageHeaders[index];
    return new RequestTotalItemsCountEstimate();
 }
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:RequestTotalItemsCountEstimate.cs

示例4: GetHeaderString

 public static string GetHeaderString(MessageHeaders headers, string name, string ns)
 {
     string str = null;
     int headerIndex = headers.FindHeader(name, ns);
     if (headerIndex >= 0)
     {
         using (XmlDictionaryReader reader = headers.GetReaderAtHeader(headerIndex))
         {
             str = reader.ReadElementString();
         }
         headers.UnderstoodHeaders.Add(headers[headerIndex]);
     }
     return str;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:PeerMessageHelpers.cs

示例5: ReadFrom

 public static TotalItemsCountEstimate ReadFrom(MessageHeaders messageHeaders)
 {
    TotalItemsCountEstimate result;
    int index = messageHeaders.FindHeader(ElementName, ManagementNamespaces.Namespace);
    if (index < 0)
    {
       return null;
    }
    using (XmlDictionaryReader readerAtHeader = messageHeaders.GetReaderAtHeader(index))
    {
       result = ReadFrom(readerAtHeader);
    }
    return result;
 }
开发者ID:nickchal,项目名称:pash,代码行数:14,代码来源:TotalItemsCountEstimate.cs

示例6: GetHeaderUniqueId

 public static UniqueId GetHeaderUniqueId(MessageHeaders headers, string name, string ns)
 {
     UniqueId id = null;
     int headerIndex = headers.FindHeader(name, ns);
     if (headerIndex >= 0)
     {
         using (XmlDictionaryReader reader = headers.GetReaderAtHeader(headerIndex))
         {
             id = reader.ReadElementContentAsUniqueId();
         }
         headers.UnderstoodHeaders.Add(headers[headerIndex]);
     }
     return id;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:PeerMessageHelpers.cs

示例7: ReadFrom

      public static ResourceUriHeader ReadFrom(MessageHeaders messageHeaders)
      {
         ResourceUriHeader result;
		 int index = messageHeaders.FindHeader(ElementName, ManagementNamespaces.Namespace);
         if (index < 0)
         {
            return null;
         }
         using (XmlDictionaryReader readerAtHeader = messageHeaders.GetReaderAtHeader(index))
         {
            result = ReadFrom(readerAtHeader);
         }
         return result;
      }
开发者ID:nickchal,项目名称:pash,代码行数:14,代码来源:ResourceUriHeader.cs

示例8: ReadFrom

 public static IdentifierHeader ReadFrom(MessageHeaders messageHeaders)
 {
    IdentifierHeader result;
    int index = messageHeaders.FindHeader(ElementName, EventingActions.Namespace);
    if (index < 0)
    {
       return null;
    }
    using (XmlDictionaryReader readerAtHeader = messageHeaders.GetReaderAtHeader(index))
    {
       result = ReadFrom(readerAtHeader);
    }
    MessageHeaderInfo headerInfo = messageHeaders[index];
    return result;
 }
开发者ID:nickchal,项目名称:pash,代码行数:15,代码来源:IdentifierHeader.cs

示例9: ReadFrom

      public static FragmentTransferHeader ReadFrom(MessageHeaders messageHeaders)
      {
         FragmentTransferHeader result;
		 int index = messageHeaders.FindHeader(ElementName, ManagementNamespaces.Namespace);
         if (index < 0)
         {
            return null;
         }
         using (XmlDictionaryReader readerAtHeader = messageHeaders.GetReaderAtHeader(index))
         {
            result = ReadFrom(readerAtHeader);
         }
         MessageHeaderInfo headerInfo = messageHeaders[index];
         return result;
      }
开发者ID:nickchal,项目名称:pash,代码行数:15,代码来源:FragmentTransferHeader.cs

示例10: FindHeader

 internal static PollingDuplexSession FindHeader(MessageHeaders headers)
 {
     PollingDuplexSession info = null;
     try
     {
         int headerIndex = headers.FindHeader("Duplex", "http://schemas.microsoft.com/2008/04/netduplex");
         if (headerIndex != -1)
         {
             info = ReadHeaderValue(headers.GetReaderAtHeader(headerIndex));
         }
     }
     catch (XmlException)
     {
     }
     return info;
 }
开发者ID:akalafrancis,项目名称:sipsorcery-mono,代码行数:16,代码来源:DuplexHeader.cs

示例11: ReadFrom

 public static MaxEnvelopeSizeHeader ReadFrom(MessageHeaders messageHeaders)
 {
     MaxEnvelopeSizeHeader result;
     int index = messageHeaders.FindHeader(ElementName, Const.ManagementNamespace);
     if (index < 0)
     {
         return null;
     }
     using (XmlDictionaryReader readerAtHeader = messageHeaders.GetReaderAtHeader(index))
     {
         result = ReadFrom(readerAtHeader);
     }
     MessageHeaderInfo headerInfo = messageHeaders[index];
     if (!messageHeaders.UnderstoodHeaders.Contains(headerInfo))
     {
         messageHeaders.UnderstoodHeaders.Add(headerInfo);
     }
     return result;
 }
开发者ID:SzymonPobiega,项目名称:WS-Man.Net,代码行数:19,代码来源:MaxEnvelopeSizeHeader.cs

示例12: RemoveHeader

 /// <summary>
 /// 删除消息头
 /// </summary>
 /// <param name="headers"></param>
 /// <param name="index"></param>
 internal static void RemoveHeader(MessageHeaders headers)
 {
     if (headers.FindHeader("HeaderContext", "session") >= 0)
         headers.RemoveAt(headers.FindHeader("HeaderContext", "session"));
 }
开发者ID:wisexie,项目名称:WCFDemo,代码行数:10,代码来源:HeaderOperater.cs

示例13: RemoveAppNameHeader

 /// <summary>
 /// 删除消息头
 /// </summary>
 /// <param name="headers"></param>
 /// <param name="index"></param>
 internal static void RemoveAppNameHeader(MessageHeaders headers)
 {
     if (headers.FindHeader("AppNameHeaderContext", "appnamesession") >= 0)
         headers.RemoveAt(headers.FindHeader("AppNameHeaderContext", "appnamesession"));
 }
开发者ID:wisexie,项目名称:WCFDemo,代码行数:10,代码来源:HeaderOperater.cs

示例14: MarkHeaderAsUnderstood

		public static void MarkHeaderAsUnderstood(MessageHeaders headers, string localName, string ns)
		{
			int num = headers.FindHeader(localName, ns);
			if (-1 != num)
			{
				if (!headers.UnderstoodHeaders.Contains(headers[num]))
				{
					headers.UnderstoodHeaders.Add(headers[num]);
				}
				return;
			}
			else
			{
				return;
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:16,代码来源:XmlUtility.cs

示例15: BeforeSendRequestTest

        public void BeforeSendRequestTest()
        {
            // Arrange.
            const string HeaderName1 = "Header1";
            const string HeaderName2 = "Header2";
            const string HeaderNamespace = "TestNamespace";
            const string Actor = "TestActor";

            var oldHeader1 = MessageHeader.CreateHeader(HeaderName1, HeaderNamespace, "Test Value 1");
            var oldHeader2 = MessageHeader.CreateHeader(HeaderName2, HeaderNamespace, "Test Value 2");

            var operationContext = Mock.Create<OperationContext>();
            Mock.Arrange(() => OperationContext.Current).Returns(operationContext);

            var headerAttributes = new SoapHeaderAttributes
                                       {
                                           HeaderName = HeaderName2,
                                           HeaderNamespace = HeaderNamespace,
                                           MustUnderstand = true,
                                           Actor = Actor,
                                           Relay = true
                                       };

            var integrationExtension = new IntegrationServiceOperationContextExtension();
            integrationExtension.HeaderAttributes.Add(headerAttributes);

            var extensions = new ExtensionCollection<OperationContext>(operationContext) { integrationExtension };
            Mock.Arrange(() => operationContext.Extensions).Returns(extensions);

            var message = Mock.Create<Message>();
            var messageHeaders = new MessageHeaders(MessageVersion.Soap11) { oldHeader1, oldHeader2 };
            Mock.Arrange(() => message.Headers).Returns(messageHeaders);

            var inspector = new IntegrationServiceMessageInspector();
            
            // Act.
            var newMessage = message;
            inspector.BeforeSendRequest(ref newMessage, Mock.Create<IClientChannel>());

            // Assert.
            Assert.AreSame(message, newMessage);

            Assert.AreEqual(2, messageHeaders.Count);
            Assert.IsTrue(messageHeaders.Contains(oldHeader1));
            Assert.IsFalse(messageHeaders.Contains(oldHeader2));

            var index = messageHeaders.FindHeader(HeaderName2, HeaderNamespace, Actor);
            var newHeader2 = (XmlElementMessageHeader)messageHeaders[index];

            Assert.IsTrue(newHeader2.MustUnderstand);
            Assert.AreEqual(Actor, newHeader2.Actor);
            Assert.IsTrue(newHeader2.Relay);

            // Exceptions.
            Message nullMessage = null;

            TestsHelper.VerifyThrow<ArgumentNullException>(() => inspector.BeforeSendRequest(ref nullMessage, Mock.Create<IClientChannel>()));

            var message2 = Mock.Create<Message>();
            TestsHelper.VerifyThrow<ArgumentNullException>(() => inspector.BeforeSendRequest(ref message2, null));
        }
开发者ID:mparsin,项目名称:Elements,代码行数:61,代码来源:IntegrationServiceMessageInspectorTests.cs


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