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


C# MessageHeaders.GetReaderAtHeader方法代码示例

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


在下文中一共展示了MessageHeaders.GetReaderAtHeader方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ApplySecurityAndWriteHeaders

        public void ApplySecurityAndWriteHeaders(MessageHeaders headers, XmlDictionaryWriter writer, SecurityIdGenerator securityIdGenerator)
        {
            // There is no way to look through the headers attributes without changing the way
            // Headers.WriterStartHeader / headers.writeHeadercontents writes the header
            // So i'm using a copy that I can change without worries.
            MessageHeaders copyHeaders = new MessageHeaders(headers);

            for (int i = 0; i < headers.Count; i++)
            {
                MessageHeaderInfo header = headers[i];

                // We are not supporting another d:Security header, throw if there is already one in the message
                if (this.IsSecurityElement(header))
                {
                    throw new ArgumentException("The message already contains a d:security header.");
                }

                if (this.ShouldProtectHeader(header))
                {
                    string headerId;
                    bool idInserted;
                    this.GetHeaderId(copyHeaders.GetReaderAtHeader(i), securityIdGenerator, true, out headerId, out idInserted);

                    // Add a reference for this header
                    this.signer.AddReference(headers, i, writer, headerId, idInserted);
                }
                else
                {
                    headers.WriteHeader(i, writer);
                }
            }
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:32,代码来源:SendCompactSignatureHeader.cs

示例3: GetHeaderULong

 public static ulong GetHeaderULong(MessageHeaders headers, int index)
 {
     ulong maxValue = ulong.MaxValue;
     if (index >= 0)
     {
         using (XmlDictionaryReader reader = headers.GetReaderAtHeader(index))
         {
             maxValue = XmlConvert.ToUInt64(reader.ReadElementString());
         }
         headers.UnderstoodHeaders.Add(headers[index]);
     }
     return maxValue;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:PeerMessageHelpers.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: 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

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

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

示例13: GetReaderAtHeaderOutOfRange

		public void GetReaderAtHeaderOutOfRange ()
		{
			MessageHeaders h = new MessageHeaders (MessageVersion.Default, 1);
			h.GetReaderAtHeader (0);
		}
开发者ID:nickchal,项目名称:pash,代码行数:5,代码来源:MessageHeadersTest.cs

示例14: GetHeaderULong

 public static ulong GetHeaderULong(MessageHeaders headers, int index)
 {
     ulong result = PeerTransportConstants.MaxHopCount;
     if (index >= 0)
     {
         using (XmlDictionaryReader reader = headers.GetReaderAtHeader(index))
         {
             result = XmlConvert.ToUInt64(reader.ReadElementString());
         }
         headers.UnderstoodHeaders.Add(headers[index]);
     }
     return result;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:13,代码来源:PeerHelpers.cs


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