Inheritance: System.Xml.XmlNodeWriter
コード例 #1
0
            public GetBufferAsyncResult(int count, XmlStreamNodeWriter writer, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.count  = count;
                this.writer = writer;
                int bufferOffset = writer.offset;

                bool completeSelf = false;

                if (bufferOffset + count <= bufferLength)
                {
                    this.offset  = bufferOffset;
                    completeSelf = true;
                }
                else
                {
                    IAsyncResult result = writer.BeginFlushBuffer(PrepareAsyncCompletion(onComplete), this);
                    completeSelf = SyncContinue(result);
                }

                if (completeSelf)
                {
                    this.Complete(true);
                }
            }
コード例 #2
0
        static void OnFlushBufferCompete(IAsyncResult result)
        {
            if (result.CompletedSynchronously)
            {
                return;
            }

            XmlStreamNodeWriter thisPtr             = (XmlStreamNodeWriter)result.AsyncState;
            Exception           completionException = null;

            try
            {
                thisPtr.stream.EndWrite(result);
                thisPtr.offset = 0;
                if (Interlocked.CompareExchange(ref thisPtr.hasPendingWrite, 0, 1) != 1)
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.GetString(SR.NoAsyncWritePending)));
                }
            }
            catch (Exception ex)
            {
                if (Fx.IsFatal(ex))
                {
                    throw;
                }

                completionException = ex;
            }

            thisPtr.flushBufferState.Complete(false, completionException);
        }
コード例 #3
0
        static void GetBufferFlushComplete(IAsyncEventArgs completionState)
        {
            XmlStreamNodeWriter     thisPtr        = (XmlStreamNodeWriter)completionState.AsyncState;
            GetBufferAsyncEventArgs getBufferState = (GetBufferAsyncEventArgs)thisPtr.flushBufferState.Arguments;

            getBufferState.Result        = getBufferState.Result ?? new GetBufferEventResult();
            getBufferState.Result.Buffer = thisPtr.buffer;
            getBufferState.Result.Offset = 0;
            getBufferState.Complete(false, completionState.Exception);
        }
コード例 #4
0
ファイル: XmlBaseWriter.cs プロジェクト: er0dr1guez/corefx
 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;
 }
コード例 #5
0
            public FlushBufferAsyncResult(XmlStreamNodeWriter writer, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.writer = writer;
                bool completeSelf = true;

                if (writer.offset != 0)
                {
                    completeSelf = HandleFlushBuffer(null);
                }

                if (completeSelf)
                {
                    this.Complete(true);
                }
            }
コード例 #6
0
 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;
 }
コード例 #7
0
            public WriteBytesAsyncResult(byte[] byteBuffer, int byteOffset, int byteCount, XmlStreamNodeWriter writer, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.byteBuffer = byteBuffer;
                this.byteOffset = byteOffset;
                this.byteCount  = byteCount;
                this.writer     = writer;

                bool completeSelf = false;

                if (byteCount < bufferLength)
                {
                    completeSelf = HandleGetBuffer(null);
                }
                else
                {
                    completeSelf = HandleFlushBuffer(null);
                }

                if (completeSelf)
                {
                    this.Complete(true);
                }
            }