CopyTo() public method

public CopyTo ( System quotas ) : void
quotas System
return void
        internal static XmlDictionaryReaderQuotas GetBufferedReadQuotas(XmlDictionaryReaderQuotas encoderQuotas)
        {
            XmlDictionaryReaderQuotas bufferedReadQuotas = new XmlDictionaryReaderQuotas();
            encoderQuotas.CopyTo(bufferedReadQuotas);

            // now we have the quotas from the encoder, we need to update the values with the new quotas from the default read quotas. 
            if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxStringContentLength))
            {
                bufferedReadQuotas.MaxStringContentLength = EncoderDefaults.BufferedReadDefaultMaxStringContentLength;
            }

            if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxArrayLength))
            {
                bufferedReadQuotas.MaxArrayLength = EncoderDefaults.BufferedReadDefaultMaxArrayLength;
            }

            if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxBytesPerRead))
            {
                bufferedReadQuotas.MaxBytesPerRead = EncoderDefaults.BufferedReadDefaultMaxBytesPerRead;
            }

            if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxNameTableCharCount))
            {
                bufferedReadQuotas.MaxNameTableCharCount = EncoderDefaults.BufferedReadDefaultMaxNameTableCharCount;
            }

            if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxDepth))
            {
                bufferedReadQuotas.MaxDepth = EncoderDefaults.BufferedReadDefaultMaxDepth;
            }

            return bufferedReadQuotas;
        }
 public WebScriptMetadataMessageEncoder(XmlDictionaryReaderQuotas quotas)
 {
     this.readerQuotas = new XmlDictionaryReaderQuotas();
     quotas.CopyTo(this.readerQuotas);
     this.mediaType = this.contentType = applicationJavaScriptMediaType;
     this.innerReadMessageEncoder = new TextMessageEncodingBindingElement(MessageVersion.None, Encoding.UTF8).CreateMessageEncoderFactory().Encoder;
 }
 public PeerNodeConfig(string meshId, ulong nodeId, PeerResolver resolver, PeerMessagePropagationFilter messagePropagationFilter, System.ServiceModel.Channels.MessageEncoder encoder, Uri listenUri, IPAddress listenIPAddress, int port, long maxReceivedMessageSize, int minNeighbors, int idealNeighbors, int maxNeighbors, int maxReferrals, int connectTimeout, int maintainerInterval, PeerSecurityManager securityManager, XmlDictionaryReaderQuotas readerQuotas, long maxBufferPool, int maxSendQueueSize, int maxReceiveQueueSize)
 {
     this.connectTimeout = connectTimeout;
     this.listenIPAddress = listenIPAddress;
     this.listenUri = listenUri;
     this.maxReceivedMessageSize = maxReceivedMessageSize;
     this.minNeighbors = minNeighbors;
     this.idealNeighbors = idealNeighbors;
     this.maxNeighbors = maxNeighbors;
     this.maxReferrals = maxReferrals;
     this.maxReferralCacheSize = 50;
     this.maxResolveAddresses = 3;
     this.meshId = meshId;
     this.encoder = encoder;
     this.messagePropagationFilter = messagePropagationFilter;
     this.nodeId = nodeId;
     this.port = port;
     this.resolver = resolver;
     this.maintainerInterval = maintainerInterval;
     this.maintainerRetryInterval = new TimeSpan(0x5f5e100L);
     this.maintainerTimeout = new TimeSpan(0x47868c00L);
     this.unregisterTimeout = new TimeSpan(0x47868c00L);
     this.securityManager = securityManager;
     readerQuotas.CopyTo(this.readerQuotas);
     this.maxBufferPoolSize = maxBufferPool;
     this.maxIncomingConcurrentCalls = maxReceiveQueueSize;
     this.maxSendQueueSize = maxSendQueueSize;
 }
 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;
 }
        bool moveBodyReaderToContent = false; // false because we want the ByteStreamMessageEncoder to be compatible with previous releases

        public ByteStreamMessageEncoder(XmlDictionaryReaderQuotas quotas)
        {
            this.quotas = new XmlDictionaryReaderQuotas();
            quotas.CopyTo(this.quotas);

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

            this.maxSentMessageSizeExceededResourceString = SR.MaxSentMessageSizeExceeded("{0}");
            this.maxReceivedMessageSizeExceededResourceString = SR.MaxReceivedMessageSizeExceeded("{0}");
        }
 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;
 }
        protected override void OnOpening()
        {
            var readerQuotas = new XmlDictionaryReaderQuotas();

            readerQuotas.MaxStringContentLength = int.MaxValue;

            base.OnOpening();

            // change readerQuotas

            foreach (var ep in this.Description.Endpoints)
            {
                var binding = new CustomBinding(ep.Binding);

                readerQuotas.CopyTo(binding.Elements.Find<WebMessageEncodingBindingElement>().ReaderQuotas);

                ep.Binding = binding;
            }
        }
 public XmlDictionaryWriter OpenSection(XmlDictionaryReaderQuotas quotas)
 {
     if (this.bufferState != BufferState.Created)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.CreateInvalidStateException());
     }
     this.bufferState = BufferState.Writing;
     this.quotas = new XmlDictionaryReaderQuotas();
     quotas.CopyTo(this.quotas);
     if (this.writer == null)
     {
         this.writer = XmlDictionaryWriter.CreateBinaryWriter(this.stream, XD.Dictionary, null, true);
     }
     else
     {
         ((IXmlBinaryWriterInitializer) this.writer).SetOutput(this.stream, XD.Dictionary, null, true);
     }
     return this.writer;
 }
            public WebMessageEncoder(Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, XmlDictionaryReaderQuotas quotas, WebContentTypeMapper contentTypeMapper, bool javascriptCallbackEnabled)
            {
                if (writeEncoding == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
                }

                this.thisLock = new object();

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

                this.maxReadPoolSize = maxReadPoolSize;
                this.maxWritePoolSize = maxWritePoolSize;
                this.contentTypeMapper = contentTypeMapper;
                this.javascriptCallbackEnabled = javascriptCallbackEnabled;

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

                this.defaultContentType = GetContentType(defaultMediaType, writeEncoding);
            }
示例#10
0
        public BinaryMessageEncoderFactory(MessageVersion messageVersion, int maxReadPoolSize, int maxWritePoolSize, int maxSessionSize,
            XmlDictionaryReaderQuotas readerQuotas, long maxReceivedMessageSize, BinaryVersion version, CompressionFormat compressionFormat)
        {
            _messageVersion = messageVersion;
            _maxReadPoolSize = maxReadPoolSize;
            _maxWritePoolSize = maxWritePoolSize;
            _maxSessionSize = maxSessionSize;
            _thisLock = new object();

            _readerQuotas = new XmlDictionaryReaderQuotas();
            if (readerQuotas != null)
            {
                readerQuotas.CopyTo(_readerQuotas);
            }

            _bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(_readerQuotas);
            this.MaxReceivedMessageSize = maxReceivedMessageSize;

            _binaryVersion = version;
            _compressionFormat = compressionFormat;
            _messageEncoder = new BinaryMessageEncoder(this, false, 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);
        }
 public XmlDictionaryReaderQuotas()
 {
     defaultQuota.CopyTo(this);
 }
示例#13
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)));
                }
            }
示例#14
0
 public XmlDictionaryWriter OpenSection(XmlDictionaryReaderQuotas quotas)
 {
     if (_bufferState != BufferState.Created)
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateInvalidStateException());
     _bufferState = BufferState.Writing;
     _quotas = new XmlDictionaryReaderQuotas();
     quotas.CopyTo(_quotas);
     if (_writer != null)
     {
         // We always want to Dispose of the writer now; previously, writers could be reassigned 
         // to a new stream, with a new dictionary and session. 
         var thisWriter = _writer;
         thisWriter.Dispose();
         _writer = null;
     }
     _writer = XmlDictionaryWriter.CreateBinaryWriter(_stream, XD.Dictionary, null, true);
     return _writer;
 }
            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(");");
            }
示例#16
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);
                _writeEncoding = writeEncoding;
                _optimizeWriteForUTF8 = IsUTF8Encoding(writeEncoding);

                _thisLock = new object();

                _version = version;
                _maxReadPoolSize = maxReadPoolSize;
                _maxWritePoolSize = maxWritePoolSize;

                _readerQuotas = new XmlDictionaryReaderQuotas();
                quotas.CopyTo(_readerQuotas);
                _bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(_readerQuotas);

                _mediaType = TextMessageEncoderFactory.GetMediaType(version);
                _contentType = TextMessageEncoderFactory.GetContentType(_mediaType, writeEncoding);
                if (version.Envelope == EnvelopeVersion.Soap12)
                {
                    _contentEncodingMap = TextMessageEncoderFactory.Soap12Content;
                }
                else if (version.Envelope == EnvelopeVersion.Soap11)
                {
                    // public profile does not allow SOAP1.1/WSA1.0. However, the EnvelopeVersion 1.1 is supported. Need to know what the implications are here
                    // but I think that it's not necessary to have here since we're a sender in N only. 
                    _contentEncodingMap = TextMessageEncoderFactory.Soap11Content;
                }
                else if (version.Envelope == EnvelopeVersion.None)
                {
                    _contentEncodingMap = TextMessageEncoderFactory.SoapNoneContent;
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                        SR.Format(SR.EnvelopeVersionNotSupported, version.Envelope)));
                }
            }