WriteStartHeader() public méthode

public WriteStartHeader ( XmlDictionaryWriter writer, System.ServiceModel.Channels.MessageVersion version ) : void
writer System.Xml.XmlDictionaryWriter
version System.ServiceModel.Channels.MessageVersion
Résultat void
Exemple #1
0
        public void WriteStartHeader(int index, XmlDictionaryWriter writer)
        {
            if (index > l.Count)
            {
                throw new ArgumentOutOfRangeException("There is no header at position " + index + ".");
            }

            MessageHeader h = l [index] as MessageHeader;

            h.WriteStartHeader(writer, version);
        }
        string GetSignatureHash(MessageHeader header, string headerId, IPrefixGenerator prefixGenerator, XmlDictionaryWriter writer, out byte[] hash)
        {
            HashStream hashStream = TakeHashStream();
            XmlDictionaryWriter effectiveWriter;
            XmlBuffer canonicalBuffer = null;

            if (writer.CanCanonicalize)
            {
                effectiveWriter = writer;
            }
            else
            {
                canonicalBuffer = new XmlBuffer(int.MaxValue);
                effectiveWriter = canonicalBuffer.OpenSection(XmlDictionaryReaderQuotas.Max);
            }

            effectiveWriter.StartCanonicalization(hashStream, false, null);

            header.WriteStartHeader(effectiveWriter, this.Version);
            if (headerId == null)
            {
                headerId = GenerateId();
                this.StandardsManager.IdManager.WriteIdAttribute(effectiveWriter, headerId);
            }
            header.WriteHeaderContents(effectiveWriter, this.Version);
            effectiveWriter.WriteEndElement();
            effectiveWriter.EndCanonicalization();
            effectiveWriter.Flush();

            if (!ReferenceEquals(effectiveWriter, writer))
            {
                Fx.Assert(canonicalBuffer != null, "Canonical buffer cannot be null.");
                canonicalBuffer.CloseSection();
                canonicalBuffer.Close();
                XmlDictionaryReader dicReader = canonicalBuffer.GetReader(0);
                writer.WriteNode(dicReader, false);
                dicReader.Close();
            }

            hash = hashStream.FlushHashAndGetValue();

            return headerId;
        }
 private string GetSignatureHash(MessageHeader header, string headerId, IPrefixGenerator prefixGenerator, XmlDictionaryWriter writer, out byte[] hash)
 {
     XmlDictionaryWriter writer2;
     HashStream stream = this.TakeHashStream();
     XmlBuffer buffer = null;
     if (writer.CanCanonicalize)
     {
         writer2 = writer;
     }
     else
     {
         buffer = new XmlBuffer(0x7fffffff);
         writer2 = buffer.OpenSection(XmlDictionaryReaderQuotas.Max);
     }
     writer2.StartCanonicalization(stream, false, null);
     header.WriteStartHeader(writer2, base.Version);
     if (headerId == null)
     {
         headerId = base.GenerateId();
         base.StandardsManager.IdManager.WriteIdAttribute(writer2, headerId);
     }
     header.WriteHeaderContents(writer2, base.Version);
     writer2.WriteEndElement();
     writer2.EndCanonicalization();
     writer2.Flush();
     if (!object.ReferenceEquals(writer2, writer))
     {
         buffer.CloseSection();
         buffer.Close();
         XmlDictionaryReader reader = buffer.GetReader(0);
         writer.WriteNode(reader, false);
         reader.Close();
     }
     hash = stream.FlushHashAndGetValue();
     return headerId;
 }