internal override void WriteTimestamp(XmlDictionaryWriter writer, SecurityTimestamp timestamp)
 {
     writer.WriteStartElement(System.ServiceModel.XD.UtilityDictionary.Prefix.Value, System.ServiceModel.XD.UtilityDictionary.Timestamp, System.ServiceModel.XD.UtilityDictionary.Namespace);
     writer.WriteAttributeString(System.ServiceModel.XD.UtilityDictionary.IdAttribute, System.ServiceModel.XD.UtilityDictionary.Namespace, timestamp.Id);
     writer.WriteStartElement(System.ServiceModel.XD.UtilityDictionary.CreatedElement, System.ServiceModel.XD.UtilityDictionary.Namespace);
     char[] creationTimeChars = timestamp.GetCreationTimeChars();
     writer.WriteChars(creationTimeChars, 0, creationTimeChars.Length);
     writer.WriteEndElement();
     writer.WriteStartElement(System.ServiceModel.XD.UtilityDictionary.ExpiresElement, System.ServiceModel.XD.UtilityDictionary.Namespace);
     char[] expiryTimeChars = timestamp.GetExpiryTimeChars();
     writer.WriteChars(expiryTimeChars, 0, expiryTimeChars.Length);
     writer.WriteEndElement();
     writer.WriteEndElement();
 }
            internal override void WriteTimestamp(XmlDictionaryWriter writer, SecurityTimestamp timestamp)
            {
                writer.WriteStartElement(XD.UtilityDictionary.Prefix.Value, XD.UtilityDictionary.Timestamp, XD.UtilityDictionary.Namespace);
                writer.WriteAttributeString(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace, timestamp.Id);

                writer.WriteStartElement(XD.UtilityDictionary.CreatedElement, XD.UtilityDictionary.Namespace);
                char[] creationTime = timestamp.GetCreationTimeChars();
                writer.WriteChars(creationTime, 0, creationTime.Length);
                writer.WriteEndElement(); // wsu:Created

                writer.WriteStartElement(XD.UtilityDictionary.ExpiresElement, XD.UtilityDictionary.Namespace);
                char[] expiryTime = timestamp.GetExpiryTimeChars();
                writer.WriteChars(expiryTime, 0, expiryTime.Length);
                writer.WriteEndElement(); // wsu:Expires

                writer.WriteEndElement();
            }
 /// <summary>
 /// When overridden in a derived class, writes text one buffer at a time.
 /// </summary>
 /// <param name="buffer">Character array containing the text to write.</param>
 /// <param name="index">The position in the buffer indicating the start of the text to write.</param>
 /// <param name="count">The number of characters to write.</param>
 public override void WriteChars(char[] buffer, int index, int count)
 {
     _innerWriter.WriteChars(buffer, index, count);
     if (_tracingWriter != null)
     {
         _tracingWriter.WriteChars(buffer, index, count);
     }
 }
Ejemplo n.º 4
0
        public void UseCase2()
        {
            XmlDictionary       dic   = new XmlDictionary();
            MemoryStream        ms    = new MemoryStream();
            XmlDictionaryWriter w     = XmlDictionaryWriter.CreateBinaryWriter(ms, dic, null);
            XmlDictionaryString empty = dic.Add(String.Empty);

            // empty ns
            w.WriteStartElement(dic.Add("FOO"), empty);
            // non-dic string
            w.WriteStartElement("BAR");
            // second time ns
            w.WriteStartElement(dic.Add("FOO"), empty);
            // first time dic string but prior non-dic name existed
            w.WriteStartElement(dic.Add("BAR"), empty);
            w.WriteEndElement();
            w.WriteEndElement();
            w.WriteEndElement();
            // dicstr w/ ns with empty prefix
            w.WriteStartElement(dic.Add("BAR"), dic.Add("urn:bar"));
            // with prefix
            w.WriteStartElement("ppp", dic.Add("BAR"), dic.Add("urn:bar"));
            w.WriteChars(new char [] { 'x', 'y', 'z' }, 0, 3);
//			w.WriteString ("xyz"); // the same as WriteChars()
            w.WriteEndElement();
            w.WriteString("bbbb");
            w.WriteCData("ccc");
            w.WriteValue(new Guid("11112222333344445555666677778888"));
            w.WriteEndElement();
            w.WriteStartElement("FOO");
            w.WriteStartAttribute("AAA");
            w.WriteValue(new Guid("11112222333344445555666677778888"));
            w.WriteEndAttribute();
            w.WriteStartAttribute("BBB");
            w.WriteValue(TimeSpan.Zero);
            w.WriteEndAttribute();
            w.WriteStartAttribute("CC");
            w.WriteValue(new UniqueId("uuid-00000000-0000-0000-0000-000000000000-1"));
            w.WriteEndAttribute();
            w.WriteStartElement("XX");
            w.WriteValue(true);
            w.WriteValue(false);
            w.WriteEndElement();
            w.WriteStartElement("xx", "aaa", "urn:zzz");
            w.WriteEndElement();
            w.WriteEndElement();

            w.Close();

            Assert.AreEqual(usecase2_result, ms.ToArray());
        }
 public override void WriteChars(char[] buffer, int index, int count)
 {
     _innerWriter.WriteChars(buffer, index, count);
 }
Ejemplo n.º 6
0
        public static async Task WriteNodeAsync(XmlDictionaryWriter writer, XmlReader reader, bool defattr)
        {
            char[]    writeNodeBuffer     = null;
            const int WriteNodeBufferSize = 1024;

            if (null == reader)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            bool canReadChunk = reader.CanReadValueChunk;
            int  d            = reader.NodeType == XmlNodeType.None ? -1 : reader.Depth;

            do
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
                    writer.WriteAttributes(reader, defattr);
                    if (reader.IsEmptyElement)
                    {
                        writer.WriteEndElement();
                        break;
                    }
                    break;

                case XmlNodeType.Text:
                    if (canReadChunk)
                    {
                        if (writeNodeBuffer == null)
                        {
                            writeNodeBuffer = new char[WriteNodeBufferSize];
                        }
                        int read;
                        while ((read = reader.ReadValueChunk(writeNodeBuffer, 0, WriteNodeBufferSize)) > 0)
                        {
                            writer.WriteChars(writeNodeBuffer, 0, read);
                        }
                    }
                    else
                    {
                        writer.WriteString(await reader.GetValueAsync());
                    }
                    break;

                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    writer.WriteWhitespace(await reader.GetValueAsync());
                    break;

                case XmlNodeType.CDATA:
                    writer.WriteCData(await reader.GetValueAsync());
                    break;

                case XmlNodeType.EntityReference:
                    writer.WriteEntityRef(reader.Name);
                    break;

                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.ProcessingInstruction:
                    writer.WriteProcessingInstruction(reader.Name, await reader.GetValueAsync());
                    break;

                case XmlNodeType.DocumentType:
                    writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), await reader.GetValueAsync());
                    break;

                case XmlNodeType.Comment:
                    writer.WriteComment(await reader.GetValueAsync());
                    break;

                case XmlNodeType.EndElement:
                    writer.WriteFullEndElement();
                    break;
                }
            } while (await reader.ReadAsync() && (d < reader.Depth || (d == reader.Depth && reader.NodeType == XmlNodeType.EndElement)));
        }