コード例 #1
0
 public UTF8BufferedMessageData(TextMessageEncoder messageEncoder, int maxReaderPoolSize)
     : base(messageEncoder.RecycledStatePool)
 {
     _messageEncoder = messageEncoder;
     _readerPool     = new Pool <XmlDictionaryReader>(maxReaderPoolSize);
     _onClose        = new OnXmlDictionaryReaderClose(OnXmlReaderClosed);
 }
 public MtomMessageEncoder(System.ServiceModel.Channels.MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, int maxBufferSize, XmlDictionaryReaderQuotas quotas)
 {
     if (version == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("version");
     }
     if (writeEncoding == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
     }
     TextEncoderDefaults.ValidateEncoding(writeEncoding);
     this.writeEncoding = writeEncoding;
     this.maxReadPoolSize = maxReadPoolSize;
     this.maxWritePoolSize = maxWritePoolSize;
     this.readerQuotas = new XmlDictionaryReaderQuotas();
     quotas.CopyTo(this.readerQuotas);
     this.maxBufferSize = maxBufferSize;
     this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(this.ReturnStreamedReader);
     this.thisLock = new object();
     if (version.Envelope == EnvelopeVersion.Soap12)
     {
         this.contentEncodingMap = TextMessageEncoderFactory.Soap12Content;
     }
     else
     {
         if (version.Envelope != EnvelopeVersion.Soap11)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid MessageVersion", new object[0])));
         }
         this.contentEncodingMap = TextMessageEncoderFactory.Soap11Content;
     }
     this.version = version;
 }
コード例 #3
0
ファイル: XmlBinaryReader.cs プロジェクト: dotnet/corefx
 private void MoveToInitial(XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose)
 {
     MoveToInitial(quotas);
     _maxBytesPerRead = quotas.MaxBytesPerRead;
     _arrayState = ArrayState.None;
     _isTextWithEndElement = false;
 }
コード例 #4
0
 /// <summary>
 /// Constructs a <see cref="PoxBinaryBufferedMessageData"/>.
 /// </summary>
 /// <param name="buffer">The message contents.</param>
 /// <param name="bufferManager">The buffer manager from which
 /// <paramref name="buffer"/> came.</param>
 /// <param name="encoder">The encoder producing the message contents.</param>
 internal PoxBinaryBufferedMessageData(ArraySegment <byte> buffer,
                                       BufferManager bufferManager, PoxBinaryMessageEncoder encoder)
     : this(buffer, encoder)
 {
     this._bufferManager = bufferManager;
     this._onReaderClose = new OnXmlDictionaryReaderClose(this.OnReaderClose);
 }
コード例 #5
0
            public JsonMessageEncoder(Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas, bool crossDomainScriptAccessEnabled)
            {
                if (writeEncoding == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
                }

                thisLock = new object();

                TextEncoderDefaults.ValidateEncoding(writeEncoding);
                this.writeEncoding = writeEncoding;

                this.maxReadPoolSize  = maxReadPoolSize;
                this.maxWritePoolSize = maxWritePoolSize;

                this.readerQuotas          = new XmlDictionaryReaderQuotas();
                this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader);
                quotas.CopyTo(this.readerQuotas);

                this.bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(this.readerQuotas);

                this.contentType = WebMessageEncoderFactory.GetContentType(JsonGlobals.applicationJsonMediaType, writeEncoding);
                this.crossDomainScriptAccessEnabled = crossDomainScriptAccessEnabled;
                this.encodedClosingFunctionCall     = this.writeEncoding.GetBytes(");");
            }
コード例 #6
0
 public MtomMessageEncoder(System.ServiceModel.Channels.MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, int maxBufferSize, XmlDictionaryReaderQuotas quotas)
 {
     if (version == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("version");
     }
     if (writeEncoding == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
     }
     TextEncoderDefaults.ValidateEncoding(writeEncoding);
     this.writeEncoding    = writeEncoding;
     this.maxReadPoolSize  = maxReadPoolSize;
     this.maxWritePoolSize = maxWritePoolSize;
     this.readerQuotas     = new XmlDictionaryReaderQuotas();
     quotas.CopyTo(this.readerQuotas);
     this.maxBufferSize         = maxBufferSize;
     this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(this.ReturnStreamedReader);
     this.thisLock = new object();
     if (version.Envelope == EnvelopeVersion.Soap12)
     {
         this.contentEncodingMap = TextMessageEncoderFactory.Soap12Content;
     }
     else
     {
         if (version.Envelope != EnvelopeVersion.Soap11)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid MessageVersion", new object[0])));
         }
         this.contentEncodingMap = TextMessageEncoderFactory.Soap11Content;
     }
     this.version = version;
 }
コード例 #7
0
 public void SetInput(Stream stream, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose)
 {
     SetReadEncodings(encodings);
     CheckContentType(contentType);
     Initialize(stream, contentType, quotas, maxBufferSize);
     this.onClose = onClose;
 }
コード例 #8
0
        private void Initialize(IXmlDictionary dictionary,
                                XmlDictionaryReaderQuotas quotas,
                                XmlBinaryReaderSession session,
                                OnXmlDictionaryReaderClose onClose)
        {
            if (quotas == null)
            {
                throw new ArgumentNullException("quotas");
            }
            if (dictionary == null)
            {
                dictionary = new XmlDictionary();
            }
            this.dictionary = dictionary;

            this.quota = quotas;

            if (session == null)
            {
                session = new XmlBinaryReaderSession();
            }
            this.session = session;

            on_close = onClose;
            NameTable nt = new NameTable();

            this.context = new XmlParserContext(nt,
                                                new XmlNamespaceManager(nt),
                                                null, XmlSpace.None);

            current = node = new NodeInfo();
            current.Reset();
            node_stack.Add(node);
        }
コード例 #9
0
 public MtomBufferedMessageData(MtomMessageEncoder messageEncoder, int maxReaderPoolSize)
     : base(messageEncoder.RecycledStatePool)
 {
     this.messageEncoder = messageEncoder;
     readerPool          = new Pool <XmlDictionaryReader>(maxReaderPoolSize);
     onClose             = new OnXmlDictionaryReaderClose(OnXmlReaderClosed);
 }
コード例 #10
0
 public static XmlDictionaryReader CreateTextReader(
     byte [] buffer, int offset, int count,
     Encoding encoding,
     XmlDictionaryReaderQuotas quotas,
     OnXmlDictionaryReaderClose onClose)
 {
     return(CreateTextReader(new MemoryStream(buffer, offset, count), encoding, quotas, onClose));
 }
コード例 #11
0
 public static XmlDictionaryReader CreateMtomReader(
     Stream stream, Encoding [] encodings, string contentType,
     XmlDictionaryReaderQuotas quotas,
     int maxBufferSize,
     OnXmlDictionaryReaderClose onClose)
 {
     return(new XmlMtomDictionaryReader(stream, encodings, contentType, quotas, maxBufferSize, onClose));
 }
コード例 #12
0
 public static XmlDictionaryReader CreateMtomReader(
     byte [] buffer, int offset, int count,
     Encoding [] encodings, string contentType,
     XmlDictionaryReaderQuotas quotas,
     int maxBufferSize,
     OnXmlDictionaryReaderClose onClose)
 {
     return(CreateMtomReader(new MemoryStream(buffer, offset, count), encodings, contentType, quotas, maxBufferSize, onClose));
 }
コード例 #13
0
 public static XmlDictionaryReader CreateBinaryReader(
     Stream stream, IXmlDictionary dictionary,
     XmlDictionaryReaderQuotas quotas,
     XmlBinaryReaderSession session,
     OnXmlDictionaryReaderClose onClose)
 {
     return(new XmlBinaryDictionaryReader(stream,
                                          dictionary, quotas, session, onClose));
 }
コード例 #14
0
ファイル: JsonReader.cs プロジェクト: pmq20/mono_forked
 public override void Close()
 {
     if (on_close != null)
     {
         on_close(this);
         on_close = null;
     }
     read_state = ReadState.Closed;
 }
コード例 #15
0
 public XmlBinaryDictionaryReader(Stream stream,
                                  IXmlDictionary dictionary,
                                  XmlDictionaryReaderQuotas quota,
                                  XmlBinaryReaderSession session,
                                  OnXmlDictionaryReaderClose onClose)
 {
     source = new StreamSource(stream);
     Initialize(dictionary, quota, session, onClose);
 }
コード例 #16
0
 public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count,
                                                      IXmlDictionary dictionary,
                                                      XmlDictionaryReaderQuotas quotas,
                                                      XmlBinaryReaderSession session,
                                                      OnXmlDictionaryReaderClose onClose)
 {
     XmlBinaryReader reader = new XmlBinaryReader();
     reader.SetInput(buffer, offset, count, dictionary, quotas, session, onClose);
     return reader;
 }
コード例 #17
0
 public XmlBinaryDictionaryReader(byte [] buffer, int offset,
                                  int count, IXmlDictionary dictionary,
                                  XmlDictionaryReaderQuotas quota,
                                  XmlBinaryReaderSession session,
                                  OnXmlDictionaryReaderClose onClose)
 {
     source = /*new ArraySource (buffer, offset, count);*/
              new StreamSource(new MemoryStream(buffer, offset, count));
     Initialize(dictionary, quota, session, onClose);
 }
コード例 #18
0
 public static XmlDictionaryReader CreateBinaryReader(
     byte [] buffer, int offset, int count,
     IXmlDictionary dictionary,
     XmlDictionaryReaderQuotas quotas,
     XmlBinaryReaderSession session,
     OnXmlDictionaryReaderClose onClose)
 {
     return(new XmlBinaryDictionaryReader(buffer,
                                          offset, count,
                                          dictionary, quotas, session, onClose));
 }
コード例 #19
0
ファイル: XmlBinaryReader.cs プロジェクト: dotnet/corefx
 public void SetInput(Stream stream,
                      IXmlDictionary dictionary,
                     XmlDictionaryReaderQuotas quotas,
                     XmlBinaryReaderSession session,
                     OnXmlDictionaryReaderClose onClose)
 {
     if (stream == null)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream));
     MoveToInitial(quotas, session, null);
     BufferReader.SetBuffer(stream, dictionary, session);
     _buffered = false;
 }
コード例 #20
0
		public XmlSimpleDictionaryReader (XmlReader reader,
			XmlDictionary dictionary, OnXmlDictionaryReaderClose onClose)
		{
			this.reader = reader;
			this.onClose = onClose;
			as_line_info = reader as IXmlLineInfo;
			as_dict_reader = reader as XmlDictionaryReader;

			if (dictionary == null)
				dictionary = new XmlDictionary ();
			dict = dictionary;
		}
コード例 #21
0
        public static XmlDictionaryReader CreateTextReader(
            Stream stream, Encoding encoding,
            XmlDictionaryReaderQuotas quotas,
            OnXmlDictionaryReaderClose onClose)
        {
            XmlReaderSettings   s   = new XmlReaderSettings();
            XmlNameTable        nt  = new NameTable();
            XmlParserContext    c   = new XmlParserContext(nt, new XmlNamespaceManager(nt), String.Empty, XmlSpace.None, encoding);
            XmlDictionaryReader res = new XmlSimpleDictionaryReader(XmlReader.Create(stream, s, c), null, onClose);

            res.quotas = quotas;
            return(res);
        }
コード例 #22
0
      /// <summary>
      /// Creates a <see cref="XmlDictionaryReader"/> for the specified <paramref name="stream"/>
      /// </summary>
      /// <param name="stream">A stream that holds the XML to be read.</param>
      /// <param name="ownStream">Specifies if the stream should be closed when the reader is closed.</param>
      /// <param name="encoding">The encoding of the text stored in <paramref name="stream" /></param>
      private static XmlDictionaryReader GetXmlReader(Stream stream, bool ownStream, Encoding encoding = null)
      {
         encoding = encoding ?? Encoding.UTF8;

         OnXmlDictionaryReaderClose onClose = ownStream ?
            (r => stream.Close()) : (OnXmlDictionaryReaderClose)null;

         return XmlDictionaryReader.CreateTextReader(
            stream,
            encoding,
            new XmlDictionaryReaderQuotas(),
            onClose);
      }
コード例 #23
0
        public XmlSimpleDictionaryReader(XmlReader reader,
                                         XmlDictionary dictionary, OnXmlDictionaryReaderClose onClose)
        {
            this.reader    = reader;
            this.onClose   = onClose;
            as_line_info   = reader as IXmlLineInfo;
            as_dict_reader = reader as XmlDictionaryReader;

            if (dictionary == null)
            {
                dictionary = new XmlDictionary();
            }
            dict = dictionary;
        }
コード例 #24
0
		public XmlMtomDictionaryReader (
			Stream stream, Encoding [] encodings, string contentType,
			XmlDictionaryReaderQuotas quotas,
			int maxBufferSize,
			OnXmlDictionaryReaderClose onClose)
		{
			this.stream = stream;
			this.encodings = encodings;
			content_type = contentType != null ? CreateContentType (contentType) : null;
			this.quotas = quotas;
			this.max_buffer_size = maxBufferSize;
			on_close = onClose;

			Initialize ();
		}
コード例 #25
0
            public TextMessageEncoder(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas)
            {
                if (version == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("version");
                }
                if (writeEncoding == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
                }

                TextEncoderDefaults.ValidateEncoding(writeEncoding);
                this.writeEncoding   = writeEncoding;
                optimizeWriteForUTF8 = IsUTF8Encoding(writeEncoding);

                thisLock = new object();

                this.version          = version;
                this.maxReadPoolSize  = maxReadPoolSize;
                this.maxWritePoolSize = maxWritePoolSize;

                this.readerQuotas = new XmlDictionaryReaderQuotas();
                quotas.CopyTo(this.readerQuotas);

                this.bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(this.readerQuotas);

                this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader);

                this.mediaType   = TextMessageEncoderFactory.GetMediaType(version);
                this.contentType = TextMessageEncoderFactory.GetContentType(mediaType, writeEncoding);
                if (version.Envelope == EnvelopeVersion.Soap12)
                {
                    contentEncodingMap = TextMessageEncoderFactory.Soap12Content;
                }
                else if (version.Envelope == EnvelopeVersion.Soap11)
                {
                    contentEncodingMap = TextMessageEncoderFactory.Soap11Content;
                }
                else if (version.Envelope == EnvelopeVersion.None)
                {
                    contentEncodingMap = TextMessageEncoderFactory.SoapNoneContent;
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                  SR.GetString(SR.EnvelopeVersionNotSupported, version.Envelope)));
                }
            }
 public BinaryMessageEncoderFactory(System.ServiceModel.Channels.MessageVersion messageVersion, int maxReadPoolSize, int maxWritePoolSize, int maxSessionSize, XmlDictionaryReaderQuotas readerQuotas, BinaryVersion version)
 {
     this.messageVersion = messageVersion;
     this.messageEncoder = new BinaryMessageEncoder(this, false, 0);
     this.maxReadPoolSize = maxReadPoolSize;
     this.maxWritePoolSize = maxWritePoolSize;
     this.maxSessionSize = maxSessionSize;
     this.thisLock = new object();
     this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(this.ReturnStreamedReader);
     this.readerQuotas = new XmlDictionaryReaderQuotas();
     if (readerQuotas != null)
     {
         readerQuotas.CopyTo(this.readerQuotas);
     }
     this.binaryVersion = version;
 }
 public BinaryMessageEncoderFactory(System.ServiceModel.Channels.MessageVersion messageVersion, int maxReadPoolSize, int maxWritePoolSize, int maxSessionSize, XmlDictionaryReaderQuotas readerQuotas, BinaryVersion version)
 {
     this.messageVersion        = messageVersion;
     this.messageEncoder        = new BinaryMessageEncoder(this, false, 0);
     this.maxReadPoolSize       = maxReadPoolSize;
     this.maxWritePoolSize      = maxWritePoolSize;
     this.maxSessionSize        = maxSessionSize;
     this.thisLock              = new object();
     this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(this.ReturnStreamedReader);
     this.readerQuotas          = new XmlDictionaryReaderQuotas();
     if (readerQuotas != null)
     {
         readerQuotas.CopyTo(this.readerQuotas);
     }
     this.binaryVersion = version;
 }
コード例 #28
0
        public XmlMtomDictionaryReader(
            Stream stream, Encoding [] encodings, string contentType,
            XmlDictionaryReaderQuotas quotas,
            int maxBufferSize,
            OnXmlDictionaryReaderClose onClose)
        {
            this.stream    = stream;
            this.encodings = encodings;
            content_type   = contentType != null?CreateContentType(contentType) : null;

            this.quotas          = quotas;
            this.max_buffer_size = maxBufferSize;
            on_close             = onClose;

            Initialize();
        }
コード例 #29
0
ファイル: JsonReader.cs プロジェクト: pmq20/mono_forked
 public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
 {
     if (encoding != null)
     {
         reader = new PushbackReader(stream, encoding);
     }
     else
     {
         reader = new PushbackReader(stream);
     }
     if (quotas == null)
     {
         throw new ArgumentNullException("quotas");
     }
     this.quotas   = quotas;
     this.on_close = onClose;
 }
コード例 #30
0
            public TextMessageEncoder(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas)
            {
                if (writeEncoding == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writeEncoding));
                }

                TextEncoderDefaults.ValidateEncoding(writeEncoding);
                _writeEncoding        = writeEncoding;
                _optimizeWriteForUTF8 = IsUTF8Encoding(writeEncoding);

                ThisLock = new object();

                _version         = version ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(version));
                MaxReadPoolSize  = maxReadPoolSize;
                MaxWritePoolSize = maxWritePoolSize;

                ReaderQuotas = new XmlDictionaryReaderQuotas();
                quotas.CopyTo(ReaderQuotas);

                _bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(ReaderQuotas);

                _onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader);

                _mediaType   = GetMediaType(version);
                _contentType = GetContentType(_mediaType, writeEncoding);
                if (version.Envelope == EnvelopeVersion.Soap12)
                {
                    _contentEncodingMap = Soap12Content;
                }
                else if (version.Envelope == EnvelopeVersion.Soap11)
                {
                    _contentEncodingMap = Soap11Content;
                }
                else if (version.Envelope == EnvelopeVersion.None)
                {
                    _contentEncodingMap = SoapNoneContent;
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                                  SR.Format(SR.EnvelopeVersionNotSupported, version.Envelope)));
                }
            }
コード例 #31
0
ファイル: XmlBinaryReader.cs プロジェクト: dotnet/corefx
 public void SetInput(byte[] buffer, int offset, int count,
                     IXmlDictionary dictionary,
                     XmlDictionaryReaderQuotas quotas,
                     XmlBinaryReaderSession session,
                     OnXmlDictionaryReaderClose onClose)
 {
     if (buffer == null)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(buffer));
     if (offset < 0)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
     if (offset > buffer.Length)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length)));
     if (count < 0)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
     if (count > buffer.Length - offset)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset)));
     MoveToInitial(quotas, session, null);
     BufferReader.SetBuffer(buffer, offset, count, dictionary, session);
     _buffered = true;
 }
コード例 #32
0
 public override void Close()
 {
     base.Close();
     OnXmlDictionaryReaderClose onClose = this.onClose;
     this.onClose = null;
     if (onClose != null)
     {
         try
         {
             onClose(this);
         }
         catch (Exception exception)
         {
             if (Fx.IsFatal(exception))
             {
                 throw;
             }
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception);
         }
     }
 }
コード例 #33
0
        public BinaryMessageEncoderFactory(MessageVersion messageVersion, int maxReadPoolSize, int maxWritePoolSize, int maxSessionSize,
            XmlDictionaryReaderQuotas readerQuotas, long maxReceivedMessageSize, BinaryVersion version, CompressionFormat compressionFormat)
        {
            this.messageVersion = messageVersion;
            this.maxReadPoolSize = maxReadPoolSize;
            this.maxWritePoolSize = maxWritePoolSize;
            this.maxSessionSize = maxSessionSize;
            this.thisLock = new object();
            this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader);
            this.readerQuotas = new XmlDictionaryReaderQuotas();
            if (readerQuotas != null)
            {
                readerQuotas.CopyTo(this.readerQuotas);
            }

            this.bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(this.readerQuotas);
            this.MaxReceivedMessageSize = maxReceivedMessageSize;

            this.binaryVersion = version;
            this.compressionFormat = compressionFormat;
            this.messageEncoder = new BinaryMessageEncoder(this, false, 0);
        }
コード例 #34
0
        public override void Close()
        {
            this.rowOffsets = null;
            base.Close();
            OnXmlDictionaryReaderClose onClose = this.onClose;

            this.onClose = null;
            if (onClose != null)
            {
                try
                {
                    onClose(this);
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception);
                }
            }
        }
コード例 #35
0
ファイル: MtomMessageEncoder.cs プロジェクト: HongGit/wcf
 public MtomMessageEncoderFactory(MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, int maxBufferSize, XmlDictionaryReaderQuotas quotas)
 {
     _messageVersion        = version;
     _writeEncoding         = writeEncoding;
     _maxReadPoolSize       = maxReadPoolSize;
     _maxWritePoolSize      = maxWritePoolSize;
     _maxBufferSize         = maxBufferSize;
     _readerQuotas          = quotas;
     _thisLock              = new object();
     _onStreamedReaderClose = new OnXmlDictionaryReaderClose(ReturnStreamedReader);
     if (version.Envelope == EnvelopeVersion.Soap12)
     {
         ContentEncodingMap = TextMessageEncoderFactory.Soap12Content;
     }
     else if (version.Envelope == EnvelopeVersion.Soap11)
     {
         ContentEncodingMap = TextMessageEncoderFactory.Soap11Content;
     }
     else
     {
         Fx.Assert("Invalid MessageVersion");
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid MessageVersion")));
     }
 }
コード例 #36
0
 private void MoveToInitial(XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
 {
     MoveToInitial(quotas);
     _maxBytesPerRead = quotas.MaxBytesPerRead;
     _onClose = onClose;
 }
コード例 #37
0
 public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
 {
     if (stream == null)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream");
     MoveToInitial(quotas, onClose);
     stream = new EncodingStreamWrapper(stream, encoding);
     BufferReader.SetBuffer(stream, null, null);
     _buffered = false;
 }
コード例 #38
0
ファイル: XmlJsonReader.cs プロジェクト: ChuangYang/corefx
        protected override void Dispose(bool disposing)
        {
            OnXmlDictionaryReaderClose onClose = _onReaderClose;
            _onReaderClose = null;
            ResetState();
            if (onClose != null)
            {
                try
                {
                    onClose(this);
                }
                catch (Exception e)
                {
                    if (DiagnosticUtility.IsFatal(e))
                    {
                        throw;
                    }

                    throw new Exception(SR.GenericCallbackException, e);
                }
            }
            base.Dispose(disposing);
        }
コード例 #39
0
        public static XmlDictionaryReader CreateJsonReader(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
        {
            XmlJsonReader reader = new XmlJsonReader();

            reader.SetInput(buffer, offset, count, encoding, quotas, onClose);
            return(reader);
        }
コード例 #40
0
        public void SetInput(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas,
            OnXmlDictionaryReaderClose onClose)
        {
            if (buffer == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("buffer");
            }
            if (offset < 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    new ArgumentOutOfRangeException("offset", SR.GetString(SR.ValueMustBeNonNegative)));
            }
            if (offset > buffer.Length)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    new ArgumentOutOfRangeException("offset",
                    SR.GetString(SR.JsonOffsetExceedsBufferSize, buffer.Length)));
            }
            if (count < 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    new ArgumentOutOfRangeException("count", SR.GetString(SR.ValueMustBeNonNegative)));
            }
            if (count > buffer.Length - offset)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    new ArgumentOutOfRangeException("count",
                    SR.GetString(SR.JsonSizeExceedsRemainingBufferSpace,
                    buffer.Length - offset)));
            }
            MoveToInitial(quotas, onClose);

            ArraySegment<byte> seg = JsonEncodingStreamWrapper.ProcessBuffer(buffer, offset, count, encoding);
            BufferReader.SetBuffer(seg.Array, seg.Offset, seg.Count, null, null);
            this.buffered = true;
            ResetState();
        }
 public BinaryBufferedMessageData(BinaryMessageEncoderFactory factory, int maxPoolSize) : base(factory.RecycledStatePool)
 {
     this.factory    = factory;
     this.readerPool = new Pool <XmlDictionaryReader>(maxPoolSize);
     this.onClose    = new OnXmlDictionaryReaderClose(this.OnXmlReaderClosed);
 }
コード例 #42
0
 private void MoveToInitial(XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
 {
     base.MoveToInitial(quotas);
     this.maxBytesPerRead = quotas.MaxBytesPerRead;
     this.onClose         = onClose;
 }
コード例 #43
0
		private void Initialize (IXmlDictionary dictionary,
			XmlDictionaryReaderQuotas quotas,
			XmlBinaryReaderSession session,
			OnXmlDictionaryReaderClose onClose)
		{
			if (quotas == null)
				throw new ArgumentNullException ("quotas");
			if (dictionary == null)
				dictionary = new XmlDictionary ();
			this.dictionary = dictionary;

			this.quota = quotas;

			if (session == null)
				session = new XmlBinaryReaderSession ();
			this.session = session;

			on_close = onClose;
			NameTable nt = new NameTable ();
			this.context = new XmlParserContext (nt,
				new XmlNamespaceManager (nt),
				null, XmlSpace.None);

			current = node = new NodeInfo ();
			current.Reset ();
			node_stack.Add (node);
		}
コード例 #44
0
 static public XmlDictionaryReader CreateMtomReader(byte[] buffer, int offset, int count, Encoding[] encodings, string contentType,
     XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose)
 {
     XmlMtomReader reader = new XmlMtomReader();
     reader.SetInput(buffer, offset, count, encodings, contentType, quotas, maxBufferSize, onClose);
     return reader;
 }
コード例 #45
0
 static public XmlDictionaryReader CreateMtomReader(Stream stream, Encoding[] encodings, string contentType,
     XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose)
 {
     XmlMtomReader reader = new XmlMtomReader();
     reader.SetInput(stream, encodings, contentType, quotas, maxBufferSize, onClose);
     return reader;
 }
コード例 #46
0
 static public XmlDictionaryReader CreateTextReader(Stream stream, Encoding encoding,
                                                    XmlDictionaryReaderQuotas quotas,
                                                    OnXmlDictionaryReaderClose onClose)
 {
     XmlUTF8TextReader reader = new XmlUTF8TextReader();
     reader.SetInput(stream, encoding, quotas, onClose);
     return reader;
 }
コード例 #47
0
 static public XmlDictionaryReader CreateTextReader(byte[] buffer, int offset, int count,
                                                    Encoding encoding,
                                                    XmlDictionaryReaderQuotas quotas,
                                                    OnXmlDictionaryReaderClose onClose)
 {
     XmlUTF8TextReader reader = new XmlUTF8TextReader();
     reader.SetInput(buffer, offset, count, encoding, quotas, onClose);
     return reader;
 }
コード例 #48
0
ファイル: XmlJsonReader.cs プロジェクト: ChuangYang/corefx
        public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas,
            OnXmlDictionaryReaderClose onClose)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            MoveToInitial(quotas, onClose);

            stream = new JsonEncodingStreamWrapper(stream, encoding, true);

            BufferReader.SetBuffer(stream, null, null);
            _buffered = false;
            ResetState();
        }
コード例 #49
0
ファイル: XmlJsonReader.cs プロジェクト: ChuangYang/corefx
        public void SetInput(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas,
            OnXmlDictionaryReaderClose onClose)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative);
            }
            if (offset > buffer.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.JsonOffsetExceedsBufferSize, buffer.Length));
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative);
            }
            if (count > buffer.Length - offset)
            {
                throw new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.JsonSizeExceedsRemainingBufferSpace, buffer.Length - offset));
            }
            MoveToInitial(quotas, onClose);

            ArraySegment<byte> seg = JsonEncodingStreamWrapper.ProcessBuffer(buffer, offset, count, encoding);
            BufferReader.SetBuffer(seg.Array, seg.Offset, seg.Count, null, null);
            _buffered = true;
            ResetState();
        }
コード例 #50
0
        public override void Close()
        {
            _rowOffsets = null;
            base.Close();
            OnXmlDictionaryReaderClose onClose = _onClose;
            _onClose = null;
            if (onClose != null)
            {
                try
                {
                    onClose(this);
                }
                catch (Exception e)
                {
                    if (DiagnosticUtility.IsFatal(e)) throw;

                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
                }
            }
        }
コード例 #51
0
 public UTF8BufferedMessageData(TextMessageEncoderFactory.TextMessageEncoder messageEncoder, int maxReaderPoolSize) : base(messageEncoder.RecycledStatePool)
 {
     this.messageEncoder = messageEncoder;
     this.readerPool     = new Pool <XmlDictionaryReader>(maxReaderPoolSize);
     this.onClose        = new OnXmlDictionaryReaderClose(this.OnXmlReaderClosed);
 }
コード例 #52
0
 public static XmlDictionaryReader CreateBinaryReader(Stream stream,
                                                      IXmlDictionary dictionary,
                                                      XmlDictionaryReaderQuotas quotas,
                                                      XmlBinaryReaderSession session,
                                                      OnXmlDictionaryReaderClose onClose)
 {
     XmlBinaryReader reader = new XmlBinaryReader();
     reader.SetInput(stream, dictionary, quotas, session, onClose);
     return reader;
 }
コード例 #53
0
		public XmlBinaryDictionaryReader (Stream stream,
			IXmlDictionary dictionary,
			XmlDictionaryReaderQuotas quota,
			XmlBinaryReaderSession session,
			OnXmlDictionaryReaderClose onClose)
		{
			source = new StreamSource (stream);
			Initialize (dictionary, quota, session, onClose);
		}
コード例 #54
0
		public static XmlDictionaryReader CreateJsonReader (byte [] source, int offset, int length, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose readerClose)
		{
			return new JsonReader (source, offset, length, encoding, quotas, readerClose);
		}
コード例 #55
0
 void MoveToInitial(XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
 {
     MoveToInitial(quotas);
     this.maxBytesPerRead = quotas.MaxBytesPerRead;
     this.onReaderClose = onClose;
 }
コード例 #56
0
		public static XmlDictionaryReader CreateJsonReader (Stream source, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose readerClose)
		{
			return new JsonReader (source, encoding, quotas, readerClose);
		}
コード例 #57
0
        public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas,
            OnXmlDictionaryReaderClose onClose)
        {
            if (stream == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream");
            }
            MoveToInitial(quotas, onClose);

            stream = new JsonEncodingStreamWrapper(stream, encoding, true);

            BufferReader.SetBuffer(stream, null, null);
            this.buffered = false;
            ResetState();
        }
コード例 #58
0
 public void SetInput(Stream stream, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
 {
     if (stream == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("stream");
     }
     this.MoveToInitial(quotas, onClose);
     stream = new EncodingStreamWrapper(stream, encoding);
     base.BufferReader.SetBuffer(stream, null, null);
     this.buffered = false;
 }
コード例 #59
0
 public void SetInput(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
 {
     if (buffer == null)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(buffer)));
     if (offset < 0)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
     if (offset > buffer.Length)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length)));
     if (count < 0)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
     if (count > buffer.Length - offset)
         throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset)));
     MoveToInitial(quotas, onClose);
     ArraySegment<byte> seg = EncodingStreamWrapper.ProcessBuffer(buffer, offset, count, encoding);
     BufferReader.SetBuffer(seg.Array, seg.Offset, seg.Count, null, null);
     _buffered = true;
 }
コード例 #60
0
        public void SetInput(byte[] buffer, int offset, int count, Encoding encoding, XmlDictionaryReaderQuotas quotas, OnXmlDictionaryReaderClose onClose)
        {
            if (buffer == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("buffer"));
            }
            if (offset < 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", System.Runtime.Serialization.SR.GetString("ValueMustBeNonNegative")));
            }
            if (offset > buffer.Length)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("offset", System.Runtime.Serialization.SR.GetString("OffsetExceedsBufferSize", new object[] { buffer.Length })));
            }
            if (count < 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", System.Runtime.Serialization.SR.GetString("ValueMustBeNonNegative")));
            }
            if (count > (buffer.Length - offset))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("count", System.Runtime.Serialization.SR.GetString("SizeExceedsRemainingBufferSpace", new object[] { buffer.Length - offset })));
            }
            this.MoveToInitial(quotas, onClose);
            ArraySegment <byte> segment = EncodingStreamWrapper.ProcessBuffer(buffer, offset, count, encoding);

            base.BufferReader.SetBuffer(segment.Array, segment.Offset, segment.Count, null, null);
            this.buffered = true;
        }