Inheritance: XmlStreamNodeWriter
示例#1
0
        public void SetOutput(Stream stream, bool includeComments, string[] inclusivePrefixes)
        {
            if (stream == null)
            {
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream));
            }

            if (_writer == null)
            {
                _writer = new XmlUTF8NodeWriter(s_isEscapedAttributeChar, s_isEscapedElementChar);
            }
            _writer.SetOutput(stream, false, null);

            if (_elementStream == null)
            {
                _elementStream = new MemoryStream();
            }

            if (_elementWriter == null)
            {
                _elementWriter = new XmlUTF8NodeWriter(s_isEscapedAttributeChar, s_isEscapedElementChar);
            }
            _elementWriter.SetOutput(_elementStream, false, null);

            if (_xmlnsAttributes == null)
            {
                _xmlnsAttributeCount = 0;
                _xmlnsOffset         = 0;
                WriteXmlnsAttribute("xml", "http://www.w3.org/XML/1998/namespace");
                WriteXmlnsAttribute("xmlns", xmlnsNamespace);
                WriteXmlnsAttribute(string.Empty, string.Empty);
                _xmlnsStartOffset = _xmlnsOffset;
                for (int i = 0; i < 3; i++)
                {
                    _xmlnsAttributes[i].referred = true;
                }
            }
            else
            {
                _xmlnsAttributeCount = 3;
                _xmlnsOffset         = _xmlnsStartOffset;
            }

            _depth             = 0;
            _inStartElement    = false;
            _includeComments   = includeComments;
            _inclusivePrefixes = null;
            if (inclusivePrefixes != null)
            {
                _inclusivePrefixes = new string[inclusivePrefixes.Length];
                for (int i = 0; i < inclusivePrefixes.Length; ++i)
                {
                    if (inclusivePrefixes[i] == null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.InvalidInclusivePrefixListCollection);
                    }
                    _inclusivePrefixes[i] = inclusivePrefixes[i];
                }
            }
        }
        public void SetOutput(Stream stream, bool includeComments, string[] inclusivePrefixes)
        {
            if (stream == null)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream");

            if (writer == null)
            {
                writer = new XmlUTF8NodeWriter(isEscapedAttributeChar, isEscapedElementChar);
            }
            writer.SetOutput(stream, false, null);

            if (elementStream == null)
            {
                elementStream = new MemoryStream();
            }

            if (elementWriter == null)
            {
                elementWriter = new XmlUTF8NodeWriter(isEscapedAttributeChar, isEscapedElementChar);
            }
            elementWriter.SetOutput(elementStream, false, null);

            if (xmlnsAttributes == null)
            {
                xmlnsAttributeCount = 0;
                xmlnsOffset = 0;
                WriteXmlnsAttribute("xml", "http://www.w3.org/XML/1998/namespace");
                WriteXmlnsAttribute("xmlns", xmlnsNamespace);
                WriteXmlnsAttribute(string.Empty, string.Empty);
                xmlnsStartOffset = xmlnsOffset;
                for (int i = 0; i < 3; i++)
                {
                    xmlnsAttributes[i].referred = true;
                }
            }
            else
            {
                xmlnsAttributeCount = 3;
                xmlnsOffset = xmlnsStartOffset;
            }

            depth = 0;
            inStartElement = false;
            this.includeComments = includeComments;
            this.inclusivePrefixes = null;
            if (inclusivePrefixes != null)
            {
                this.inclusivePrefixes = new string[inclusivePrefixes.Length];
                for (int i = 0; i < inclusivePrefixes.Length; ++i)
                {
                    if (inclusivePrefixes[i] == null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.InvalidInclusivePrefixListCollection));
                    }
                    this.inclusivePrefixes[i] = inclusivePrefixes[i];
                }
            }
        }
示例#3
0
 public void SetOutput(Stream stream, bool includeComments, string[] inclusivePrefixes)
 {
     if (stream == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream");
     }
     if (this.writer == null)
     {
         this.writer = new XmlUTF8NodeWriter(isEscapedAttributeChar, isEscapedElementChar);
     }
     this.writer.SetOutput(stream, false, null);
     if (this.elementStream == null)
     {
         this.elementStream = new MemoryStream();
     }
     if (this.elementWriter == null)
     {
         this.elementWriter = new XmlUTF8NodeWriter(isEscapedAttributeChar, isEscapedElementChar);
     }
     this.elementWriter.SetOutput(this.elementStream, false, null);
     if (this.xmlnsAttributes == null)
     {
         this.xmlnsAttributeCount = 0;
         this.xmlnsOffset         = 0;
         this.WriteXmlnsAttribute("xml", "http://www.w3.org/XML/1998/namespace");
         this.WriteXmlnsAttribute("xmlns", "http://www.w3.org/2000/xmlns/");
         this.WriteXmlnsAttribute(string.Empty, string.Empty);
         this.xmlnsStartOffset = this.xmlnsOffset;
         for (int i = 0; i < 3; i++)
         {
             this.xmlnsAttributes[i].referred = true;
         }
     }
     else
     {
         this.xmlnsAttributeCount = 3;
         this.xmlnsOffset         = this.xmlnsStartOffset;
     }
     this.depth             = 0;
     this.inStartElement    = false;
     this.includeComments   = includeComments;
     this.inclusivePrefixes = null;
     if (inclusivePrefixes != null)
     {
         this.inclusivePrefixes = new string[inclusivePrefixes.Length];
         for (int j = 0; j < inclusivePrefixes.Length; j++)
         {
             if (inclusivePrefixes[j] == null)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(System.Runtime.Serialization.SR.GetString("InvalidInclusivePrefixListCollection"));
             }
             this.inclusivePrefixes[j] = inclusivePrefixes[j];
         }
     }
 }
示例#4
0
            public InternalWriteBase64TextAsyncResult(byte[] buffer, int offset, int count, XmlUTF8NodeWriter writer, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.buffer   = buffer;
                this.offset   = offset;
                this.count    = count;
                this.writer   = writer;
                this.encoding = XmlConverter.Base64Encoding;

                bool completeSelf = ContinueWork();

                if (completeSelf)
                {
                    this.Complete(true);
                }
            }
示例#5
0
            public WriteBase64TextAsyncResult(byte[] trailBytes, int trailByteCount, byte[] buffer, int offset, int count, XmlUTF8NodeWriter writer, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.writer         = writer;
                this.trailBytes     = trailBytes;
                this.trailByteCount = trailByteCount;
                this.buffer         = buffer;
                this.offset         = offset;
                this.count          = count;

                bool completeSelf = HandleWriteTrailBytes(null);

                if (completeSelf)
                {
                    this.Complete(true);
                }
            }
示例#6
0
        public void SetOutput(Stream stream, Encoding encoding, bool ownsStream)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");
            if (encoding == null)
                throw new ArgumentNullException("encoding");
            if (encoding.WebName != Encoding.UTF8.WebName)
            {
                stream = new EncodingStreamWrapper(stream, encoding, true);
            }

            if (_writer == null)
            {
                _writer = new XmlUTF8NodeWriter();
            }
            _writer.SetOutput(stream, ownsStream, encoding);
            SetOutput(_writer);
        }
        public void SetOutput(Stream stream, Encoding encoding, bool ownsStream)
        {
            if (stream == null)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream");
            if (encoding == null)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("encoding");
            if (encoding.WebName != Encoding.UTF8.WebName)
            {
                stream = new EncodingStreamWrapper(stream, encoding, true);
            }

            if (writer == null)
            {
                writer = new XmlUTF8NodeWriter();
            }
            writer.SetOutput(stream, ownsStream, encoding);
            SetOutput(writer);
        }
示例#8
0
 public void SetOutput(Stream stream, Encoding encoding, bool ownsStream)
 {
     if (stream == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream");
     }
     if (encoding == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("encoding");
     }
     if (encoding.WebName != Encoding.UTF8.WebName)
     {
         stream = new EncodingStreamWrapper(stream, encoding, true);
     }
     if (this.writer == null)
     {
         this.writer = new XmlUTF8NodeWriter();
     }
     this.writer.SetOutput(stream, ownsStream, encoding);
     base.SetOutput(this.writer);
 }
 public void SetOutput(Stream stream, Encoding encoding, bool ownsStream)
 {
     if (stream == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream");
     }
     if (encoding == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("encoding");
     }
     if (encoding.WebName != Encoding.UTF8.WebName)
     {
         stream = new EncodingStreamWrapper(stream, encoding, true);
     }
     if (this.writer == null)
     {
         this.writer = new XmlUTF8NodeWriter();
     }
     this.writer.SetOutput(stream, ownsStream, encoding);
     base.SetOutput(this.writer);
 }
示例#10
0
        public void SetOutput(Stream stream, Encoding encoding, bool ownsStream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (encoding == null)
            {
                throw new ArgumentNullException(nameof(encoding));
            }
            if (encoding.WebName != Encoding.UTF8.WebName)
            {
                stream = new EncodingStreamWrapper(stream, encoding, true);
            }

            if (_writer == null)
            {
                _writer = new XmlUTF8NodeWriter();
            }
            _writer.SetOutput(stream, ownsStream, encoding);
            SetOutput(_writer);
        }
 public InternalWriteBase64TextAsyncWriter(XmlUTF8NodeWriter writer)
 {
     this.writer = writer;
     this.writerState = new AsyncEventArgs<XmlWriteBase64AsyncArguments>();
     this.writerArgs = new XmlWriteBase64AsyncArguments();
 }
            public InternalWriteBase64TextAsyncResult(byte[] buffer, int offset, int count, XmlUTF8NodeWriter writer, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.buffer = buffer;
                this.offset = offset;
                this.count = count;
                this.writer = writer;
                this.encoding = XmlConverter.Base64Encoding;

                bool completeSelf = ContinueWork();

                if (completeSelf)
                {
                    this.Complete(true);
                }
            }
            public WriteBase64TextAsyncResult(byte[] trailBytes, int trailByteCount, byte[] buffer, int offset, int count, XmlUTF8NodeWriter writer, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.writer = writer;
                this.trailBytes = trailBytes;
                this.trailByteCount = trailByteCount;
                this.buffer = buffer;
                this.offset = offset;
                this.count = count;

                bool completeSelf = HandleWriteTrailBytes(null);

                if (completeSelf)
                {
                    this.Complete(true);
                }
            }
        public void StartFragment(Stream stream, bool generateSelfContainedTextFragment)
        {
            if (!CanFragment)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            if (IsClosed)
                ThrowClosed();
            if (stream == null)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("stream"));
            if (oldStream != null || oldWriter != null)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException());
            if (WriteState == WriteState.Attribute)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.XmlInvalidWriteState, "StartFragment", WriteState.ToString())));
            FlushElement();
            writer.Flush();

            oldNamespaceBoundary = NamespaceBoundary;

            XmlStreamNodeWriter fragmentWriter = null;
            if (generateSelfContainedTextFragment)
            {
                this.NamespaceBoundary = depth + 1;
                if (textFragmentWriter == null)
                    textFragmentWriter = new XmlUTF8NodeWriter();
                textFragmentWriter.SetOutput(stream, false, Encoding.UTF8);
                fragmentWriter = textFragmentWriter;
            }

            if (Signing)
            {
                if (fragmentWriter != null)
                {
                    oldWriter = signingWriter.NodeWriter;
                    signingWriter.NodeWriter = fragmentWriter;
                }
                else
                {
                    oldStream = ((XmlStreamNodeWriter)signingWriter.NodeWriter).Stream;
                    ((XmlStreamNodeWriter)signingWriter.NodeWriter).Stream = stream;
                }
            }
            else
            {
                if (fragmentWriter != null)
                {
                    oldWriter = writer;
                    writer = fragmentWriter;
                }
                else
                {
                    oldStream = nodeWriter.Stream;
                    nodeWriter.Stream = stream;
                }
            }
        }
示例#15
0
 public InternalWriteBase64TextAsyncWriter(XmlUTF8NodeWriter writer)
 {
     this.writer      = writer;
     this.writerState = new AsyncEventArgs <XmlWriteBase64AsyncArguments>();
     this.writerArgs  = new XmlWriteBase64AsyncArguments();
 }
 public void StartFragment(Stream stream, bool generateSelfContainedTextFragment)
 {
     if (!this.CanFragment)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
     }
     if (this.IsClosed)
     {
         this.ThrowClosed();
     }
     if (stream == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("stream"));
     }
     if ((this.oldStream != null) || (this.oldWriter != null))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException());
     }
     if (this.WriteState == System.Xml.WriteState.Attribute)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.Runtime.Serialization.SR.GetString("XmlInvalidWriteState", new object[] { "StartFragment", this.WriteState.ToString() })));
     }
     this.FlushElement();
     this.writer.Flush();
     this.oldNamespaceBoundary = this.NamespaceBoundary;
     XmlStreamNodeWriter textFragmentWriter = null;
     if (generateSelfContainedTextFragment)
     {
         this.NamespaceBoundary = this.depth + 1;
         if (this.textFragmentWriter == null)
         {
             this.textFragmentWriter = new XmlUTF8NodeWriter();
         }
         this.textFragmentWriter.SetOutput(stream, false, Encoding.UTF8);
         textFragmentWriter = this.textFragmentWriter;
     }
     if (this.Signing)
     {
         if (textFragmentWriter != null)
         {
             this.oldWriter = this.signingWriter.NodeWriter;
             this.signingWriter.NodeWriter = textFragmentWriter;
         }
         else
         {
             this.oldStream = ((XmlStreamNodeWriter) this.signingWriter.NodeWriter).Stream;
             ((XmlStreamNodeWriter) this.signingWriter.NodeWriter).Stream = stream;
         }
     }
     else if (textFragmentWriter != null)
     {
         this.oldWriter = this.writer;
         this.writer = textFragmentWriter;
     }
     else
     {
         this.oldStream = this.nodeWriter.Stream;
         this.nodeWriter.Stream = stream;
     }
 }