public override void Close()
 {
     if (!this.IsClosed)
     {
         try
         {
             this.FinishDocument();
             this.AutoComplete(System.Xml.WriteState.Closed);
             this.writer.Flush();
         }
         finally
         {
             this.nsMgr.Close();
             if (this.depth != 0)
             {
                 this.elements = null;
                 this.depth = 0;
             }
             this.attributeValue = null;
             this.attributeLocalName = null;
             this.nodeWriter.Close();
             if (this.signingWriter != null)
             {
                 this.signingWriter.Close();
             }
             if (this.textFragmentWriter != null)
             {
                 this.textFragmentWriter.Close();
             }
             this.oldWriter = null;
             this.oldStream = null;
         }
     }
 }
Esempio n. 2
0
 public void SetOutput(XmlNodeWriter writer, Stream stream, bool includeComments, string[]?inclusivePrefixes)
 {
     _writer = writer;
     _signingWriter ??= new XmlCanonicalWriter();
     _signingWriter.SetOutput(stream, includeComments, inclusivePrefixes);
     _chars       = new byte[XmlConverter.MaxPrimitiveChars];
     _base64Chars = null;
 }
 public void SetOutput(XmlNodeWriter writer, Stream stream, bool includeComments, string[] inclusivePrefixes)
 {
     this.writer = writer;
     if (signingWriter == null)
         signingWriter = new XmlCanonicalWriter();
     this.signingWriter.SetOutput(stream, includeComments, inclusivePrefixes);
     this.chars = new byte[XmlConverter.MaxPrimitiveChars];
     this.base64Chars = null;
 }
Esempio n. 4
0
		// It is indicated by ThreadManager.StartDebug().
		internal void Run ()
		{
			custom_cache = new Hashtable ();
			transform = (XslTransform) Activator.CreateInstance (typeof (XslTransform), BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, new object [] {injector}, CultureInfo.CurrentCulture);
			debugger.LoadStylesheet (transform);
			output = new XmlNodeWriter (false);
			debugger.Transform (transform, output);

			if (Completed != null)
				Completed (this, new XsltCompleteEventArgs ());
		}
 public void SetOutput(XmlNodeWriter writer, Stream stream, bool includeComments, string[] inclusivePrefixes)
 {
     this.writer = writer;
     if (this.signingWriter == null)
     {
         this.signingWriter = new XmlCanonicalWriter();
     }
     this.signingWriter.SetOutput(stream, includeComments, inclusivePrefixes);
     this.chars       = new byte[0x40];
     this.base64Chars = null;
 }
            public WriteBase64TextAsyncResult(byte[] trailBuffer, int trailCount, byte[] buffer, int offset, int count, XmlNodeWriter nodeWriter, AsyncCallback callback, object state)
                : base(callback, state)
            {
                Fx.Assert(nodeWriter != null, "nodeWriter should never be null");

                this.trailBuffer = trailBuffer;
                this.trailCount  = trailCount;
                this.buffer      = buffer;
                this.offset      = offset;
                this.count       = count;
                this.nodeWriter  = nodeWriter;

                Schedule();
            }
Esempio n. 7
0
 protected void SetOutput(XmlStreamNodeWriter writer)
 {
     _inList = false;
     _writer = writer;
     _nodeWriter = writer;
     _writeState = WriteState.Start;
     _documentState = DocumentState.None;
     _nsMgr.Clear();
     if (_depth != 0)
     {
         _elements = null;
         _depth = 0;
     }
     _attributeLocalName = null;
     _attributeValue = null;
 }
 protected void SetOutput(XmlStreamNodeWriter writer)
 {
     this.inList = false;
     this.writer = writer;
     this.nodeWriter = writer;
     this.writeState = WriteState.Start;
     this.documentState = DocumentState.None;
     this.nsMgr.Clear();
     if (this.depth != 0)
     {
         this.elements = null;
         this.depth = 0;
     }
     this.attributeLocalName = null;
     this.attributeValue = null;
     this.oldWriter = null;
     this.oldStream = null;
 }
 public override void EndCanonicalization()
 {
     if (IsClosed)
         ThrowClosed();
     if (!Signing)
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.XmlCanonicalizationNotStarted)));
     signingWriter.Flush();
     writer = signingWriter.NodeWriter;
 }
Esempio n. 10
0
		public void Dispose ()
		{
			debugger = null;
			transform = null;
			output = null;
		}
 public override void StartCanonicalization(Stream stream, bool includeComments, string[] inclusivePrefixes)
 {
     if (this.IsClosed)
     {
         this.ThrowClosed();
     }
     if (this.Signing)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.Runtime.Serialization.SR.GetString("XmlCanonicalizationStarted")));
     }
     this.FlushElement();
     if (this.signingWriter == null)
     {
         this.signingWriter = this.CreateSigningNodeWriter();
     }
     this.signingWriter.SetOutput(this.writer, stream, includeComments, inclusivePrefixes);
     this.writer = this.signingWriter;
     this.SignScope(this.signingWriter.CanonicalWriter);
 }
        public override void Close()
        {
            if (IsClosed)
                return;

            try
            {
                FinishDocument();
                AutoComplete(WriteState.Closed);
                writer.Flush();
            }
            finally
            {
                nsMgr.Close();
                if (depth != 0)
                {
                    elements = null;
                    depth = 0;
                }
                attributeValue = null;
                attributeLocalName = null;
                nodeWriter.Close();
                if (signingWriter != null)
                {
                    signingWriter.Close();
                }
                if (textFragmentWriter != null)
                {
                    textFragmentWriter.Close();
                }
                oldWriter = null;
                oldStream = null;
            }
        }
 public void DeclareNamespaces(XmlNodeWriter writer)
 {
     int nsCount = this.nsCount;
     while (nsCount > 0)
     {
         Namespace namespace2 = this.namespaces[nsCount - 1];
         if (namespace2.Depth != this.depth)
         {
             break;
         }
         nsCount--;
     }
     while (nsCount < this.nsCount)
     {
         Namespace namespace3 = this.namespaces[nsCount];
         if (namespace3.UriDictionaryString != null)
         {
             writer.WriteXmlnsAttribute(namespace3.Prefix, namespace3.UriDictionaryString);
         }
         else
         {
             writer.WriteXmlnsAttribute(namespace3.Prefix, namespace3.Uri);
         }
         nsCount++;
     }
 }
            public WriteBase64TextAsyncResult(byte[] trailBuffer, int trailCount, byte[] buffer, int offset, int count, XmlNodeWriter nodeWriter, AsyncCallback callback, object state)
                : base(callback, state)
            {
                Fx.Assert(nodeWriter != null, "nodeWriter should never be null");

                this.trailBuffer = trailBuffer;
                this.trailCount = trailCount;
                this.buffer = buffer;
                this.offset = offset;
                this.count = count;
                this.nodeWriter = nodeWriter;

                Schedule();
            }
 public override void StartCanonicalization(Stream stream, bool includeComments, string[] inclusivePrefixes)
 {
     if (IsClosed)
         ThrowClosed();
     if (Signing)
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.XmlCanonicalizationStarted)));
     FlushElement();
     if (signingWriter == null)
         signingWriter = CreateSigningNodeWriter();
     signingWriter.SetOutput(writer, stream, includeComments, inclusivePrefixes);
     writer = signingWriter;
     SignScope(signingWriter.CanonicalWriter);
 }
 public override void EndCanonicalization()
 {
     if (this.IsClosed)
     {
         this.ThrowClosed();
     }
     if (!this.Signing)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.Runtime.Serialization.SR.GetString("XmlCanonicalizationNotStarted")));
     }
     this.signingWriter.Flush();
     this.writer = this.signingWriter.NodeWriter;
 }
 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;
     }
 }
Esempio n. 18
0
 public void DeclareNamespaces(XmlNodeWriter writer)
 {
     int i = _nsCount;
     while (i > 0)
     {
         Namespace nameSpace = _namespaces[i - 1];
         if (nameSpace.Depth != _depth)
             break;
         i--;
     }
     while (i < _nsCount)
     {
         Namespace nameSpace = _namespaces[i];
         if (nameSpace.UriDictionaryString != null)
             writer.WriteXmlnsAttribute(nameSpace.Prefix, nameSpace.UriDictionaryString);
         else
             writer.WriteXmlnsAttribute(nameSpace.Prefix, nameSpace.Uri);
         i++;
     }
 }
        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;
                }
            }
        }
        public void EndFragment()
        {
            if (IsClosed)
                ThrowClosed();
            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, "EndFragment", WriteState.ToString())));

            FlushElement();
            writer.Flush();

            if (Signing)
            {
                if (oldWriter != null)
                    signingWriter.NodeWriter = oldWriter;
                else
                    ((XmlStreamNodeWriter)signingWriter.NodeWriter).Stream = oldStream;
            }
            else
            {
                if (oldWriter != null)
                    writer = oldWriter;
                else
                    nodeWriter.Stream = oldStream;
            }
            NamespaceBoundary = oldNamespaceBoundary;
            oldWriter = null;
            oldStream = null;
        }
 public void EndFragment()
 {
     if (this.IsClosed)
     {
         this.ThrowClosed();
     }
     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[] { "EndFragment", this.WriteState.ToString() })));
     }
     this.FlushElement();
     this.writer.Flush();
     if (this.Signing)
     {
         if (this.oldWriter != null)
         {
             this.signingWriter.NodeWriter = this.oldWriter;
         }
         else
         {
             ((XmlStreamNodeWriter) this.signingWriter.NodeWriter).Stream = this.oldStream;
         }
     }
     else if (this.oldWriter != null)
     {
         this.writer = this.oldWriter;
     }
     else
     {
         this.nodeWriter.Stream = this.oldStream;
     }
     this.NamespaceBoundary = this.oldNamespaceBoundary;
     this.oldWriter = null;
     this.oldStream = null;
 }