当前位置: 首页>>代码示例>>C#>>正文


C# ChunkedMemoryStream类代码示例

本文整理汇总了C#中ChunkedMemoryStream的典型用法代码示例。如果您正苦于以下问题:C# ChunkedMemoryStream类的具体用法?C# ChunkedMemoryStream怎么用?C# ChunkedMemoryStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ChunkedMemoryStream类属于命名空间,在下文中一共展示了ChunkedMemoryStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendRequest

 internal void SendRequest(IMessage msg, ITransportHeaders headers, Stream contentStream)
 {
     IMethodCallMessage message = (IMethodCallMessage) msg;
     int length = (int) contentStream.Length;
     string uri = message.Uri;
     this._bOneWayRequest = RemotingServices.IsOneWay(message.MethodBase);
     ChunkedMemoryStream outputStream = new ChunkedMemoryStream(CoreChannel.BufferPool);
     base.WritePreambleAndVersion(outputStream);
     if (!this._bOneWayRequest)
     {
         base.WriteUInt16(0, outputStream);
     }
     else
     {
         base.WriteUInt16(1, outputStream);
     }
     base.WriteUInt16(0, outputStream);
     base.WriteInt32(length, outputStream);
     base.WriteUInt16(4, outputStream);
     base.WriteByte(1, outputStream);
     base.WriteCountedString(uri, outputStream);
     base.WriteHeaders(headers, outputStream);
     outputStream.WriteTo(base.NetStream);
     outputStream.Close();
     StreamHelper.CopyStream(contentStream, base.NetStream);
     contentStream.Close();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:IpcClientHandler.cs

示例2: Write_100_bytes

 public void Write_100_bytes()
 {
     byte[] bytes = GetBytes(100);
     var stream = new ChunkedMemoryStream();
     stream.Write(bytes, 0, bytes.Length);
     Assert.AreEqual(100, stream.Length);
 }
开发者ID:nataren,项目名称:DReAM,代码行数:7,代码来源:ChunkedMemoryStreamTest.cs

示例3: TestCreateTextDataFromStream

        public void TestCreateTextDataFromStream()
        {
            var stream = new ChunkedMemoryStream();
              var str = Encoding.ASCII.GetBytes("string");

              stream.Write(str, 0, str.Length);
              stream.Position = 0L;

              var text = ImapData.CreateTextData(stream);

              Assert.AreEqual(ImapDataFormat.Text, text.Format);
              Assert.AreEqual(6, text.GetTextLength());
              Assert.AreEqual(Encoding.ASCII.GetBytes("string"), text.GetTextAsByteArray());
              Assert.AreEqual(new ByteString(str), text.GetTextAsByteString());
              Assert.AreEqual("string", text.GetTextAsString());

              Assert.AreSame(stream, text.GetTextAsStream());

              FileAssert.AreEqual(new MemoryStream(str, false), text.GetTextAsStream());

              var buffer = new byte[3];

              text.CopyText(buffer, 0, buffer.Length);

              Assert.AreEqual(str.Slice(0, 3), buffer);
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:26,代码来源:ImapData.cs

示例4: ImapAppendMessageBodyStream

        protected internal ImapAppendMessageBodyStream(int readTimeout, int writeTimeout)
        {
            this.ReadTimeout  = readTimeout;
              this.WriteTimeout = writeTimeout;

              buffer = new ChunkedMemoryStream();
        }
开发者ID:pengyancai,项目名称:cs-util,代码行数:7,代码来源:ImapAppendMessageBodyStream.cs

示例5: GetRequestStream

 public Stream GetRequestStream(IMessage msg, int contentLength, ITransportHeaders headers)
 {
     IMethodCallMessage message = (IMethodCallMessage) msg;
     string uri = message.Uri;
     this._bOneWayRequest = RemotingServices.IsOneWay(message.MethodBase);
     ChunkedMemoryStream outputStream = new ChunkedMemoryStream(CoreChannel.BufferPool);
     base.WritePreambleAndVersion(outputStream);
     if (!this._bOneWayRequest)
     {
         base.WriteUInt16(0, outputStream);
     }
     else
     {
         base.WriteUInt16(1, outputStream);
     }
     base.WriteUInt16(0, outputStream);
     base.WriteInt32(contentLength, outputStream);
     base.WriteUInt16(4, outputStream);
     base.WriteByte(1, outputStream);
     base.WriteCountedString(uri, outputStream);
     base.WriteHeaders(headers, outputStream);
     outputStream.WriteTo(base.NetStream);
     outputStream.Close();
     this._requestStream = base.NetStream;
     return this._requestStream;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:TcpClientSocketHandler.cs

示例6: Static

		/// <summary>
		/// Create reusable stream.
		/// Disposing the stream only has the effect of resetting it.
		/// </summary>
		/// <returns></returns>
		public static ChunkedMemoryStream Static()
		{
			var cms = new ChunkedMemoryStream(new byte[BlockSize]);
			cms.GetReader();
			cms.GetWriter();
			cms.UseBufferedReader(string.Empty);
			return cms;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:13,代码来源:ChunkedMemoryStream.cs

示例7: Read_from_an_initialized_buffer

 public void Read_from_an_initialized_buffer()
 {
     var originalBytes = GetBytes(100);
     var stream = new ChunkedMemoryStream(originalBytes);
     var readBytes = new byte[100];
     stream.Read(readBytes, 0, readBytes.Length);
     Assert.AreEqual(originalBytes, readBytes);
 }
开发者ID:nataren,项目名称:DReAM,代码行数:8,代码来源:ChunkedMemoryStreamTest.cs

示例8: Write_100_bytes_100_times

 public void Write_100_bytes_100_times()
 {
     byte[] bytes = GetBytes(100);
     var stream = new ChunkedMemoryStream();
     for(int i = 0; i < 100; ++i) {
         stream.Write(bytes, 0, bytes.Length);
     }
 }
开发者ID:nataren,项目名称:DReAM,代码行数:8,代码来源:ChunkedMemoryStreamTest.cs

示例9: Serialize

		public static void Serialize(this IJsonObject instance, ChunkedMemoryStream stream)
		{
			stream.Reset();
			var sw = stream.GetWriter();
			instance.Serialize(sw, false, null);
			sw.Flush();
			stream.Position = 0;
		}
开发者ID:dstimac,项目名称:revenj,代码行数:8,代码来源:IJsonObject.cs

示例10: ResourceContentBE

 public ResourceContentBE(XDoc doc)
     : this(true) {
     if(doc == null) {
         throw new ArgumentNullException("doc");
     }
     _stream = new ChunkedMemoryStream();
     doc.WriteTo(_stream);
     _mimeType = MimeType.TEXT_XML;
     _size = (uint)_stream.Length;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:10,代码来源:ResourceContentBE.cs

示例11: Context

		public Context(IServiceProvider service)
		{
			Stream = ChunkedMemoryStream.Static();
			Writer = Stream.GetWriter();
			var dqm = service.Resolve<IDatabaseQueryManager>();
			var factory = service.Resolve<IObjectFactory>().CreateInnerFactory();
			factory.RegisterInterfaces(dqm.StartQuery(false));
			Repository = factory.Resolve<IPersistableRepository<World>>();
			BulkReader = factory.BulkRead(ChunkedMemoryStream.Static());
		}
开发者ID:cmsimike,项目名称:FrameworkBenchmarks,代码行数:10,代码来源:Context.cs

示例12: Write_100_bytes_100_times_Read_10000_bytes

        public void Write_100_bytes_100_times_Read_10000_bytes()
        {
            byte[] bytes = GetBytes(100);
            byte[][] arrays = new byte[100][];
            var stream = new ChunkedMemoryStream();
            for(int i = 0; i < 100; ++i) {
                stream.Write(bytes, 0, bytes.Length);
                arrays[i] = bytes;
            }
            stream.Position = 0;

            byte[] buffer = new byte[100 * bytes.Length];
            int read = stream.Read(buffer, 0, buffer.Length);
            Assert.AreEqual(buffer.Length, read);
            Assert.AreEqual(ArrayUtil.Concat(arrays), buffer);
            Assert.AreEqual(0, stream.Read(buffer, 0, buffer.Length));
        }
开发者ID:nataren,项目名称:DReAM,代码行数:17,代码来源:ChunkedMemoryStreamTest.cs

示例13: Write_64k_bytes_Read_64k_bytes

        public void Write_64k_bytes_Read_64k_bytes()
        {
            byte[] bytes = GetBytes(64 * 1024);
            var stream = new ChunkedMemoryStream();
            stream.Write(bytes, 0, bytes.Length);
            stream.Position = 0;

            byte[] buffer = new byte[bytes.Length];
            int read = stream.Read(buffer, 0, buffer.Length);
            Assert.AreEqual(buffer.Length, read);
            Assert.AreEqual(bytes, buffer);
            Assert.AreEqual(0, stream.Read(buffer, 0, buffer.Length));
        }
开发者ID:nataren,项目名称:DReAM,代码行数:13,代码来源:ChunkedMemoryStreamTest.cs

示例14: GetPreparedCommandStream

        private Stream GetPreparedCommandStream()
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "GetPreparedCommandText");

            if (parameters.Count == 0)
                return new MemoryStream(Encoding.UTF8.GetBytes("execute " + planName));

            var cms = new ChunkedMemoryStream();
            var sw = new StreamWriter(cms);
            sw.Write("execute " + planName);
            sw.Write('(');

            for (int i = 0; i < parameters.Count; i++)
            {
                var p = parameters[i];
                // Add parentheses wrapping parameter value before the type cast to avoid problems with Int16.MinValue, Int32.MinValue and Int64.MinValue
                // See bug #1010543
                sw.Write('(');
                //TODO fix LOH issue
                sw.Write(p.TypeInfo.ConvertToBackend(p.Value, false));
                sw.Write('(');
                if (p.UseCast)
                {
                    sw.Write("::");
                    sw.Write(p.TypeInfo.CastName);
                    if (p.TypeInfo.UseSize && (p.Size > 0))
                    {
                        sw.Write('(');
                        sw.Write(p.Size);
                        sw.Write(')');
                    }
                }
                if (i < parameters.Count - 1)
                    sw.Write(',');
            }
            sw.Write(')');
            sw.Flush();
            return cms;
        }
开发者ID:zapov,项目名称:Npgsql2,代码行数:39,代码来源:NpgsqlCommand.cs

示例15: SerializeMessage

        } // AsyncProcessMessage


        // helper function to serialize the message
        private void SerializeMessage(IMessage msg, 
                                      out ITransportHeaders headers, out Stream stream)
        {
            BaseTransportHeaders requestHeaders = new BaseTransportHeaders();
            headers = requestHeaders;

            // add other http soap headers
            requestHeaders.ContentType = CoreChannel.BinaryMimeType;
            if (_channelProtocol == SinkChannelProtocol.Http)
                headers["__RequestVerb"] = "POST";

            bool bMemStream = false;
            stream = _nextSink.GetRequestStream(msg, headers);
            if (stream == null)
            {
                stream = new ChunkedMemoryStream(CoreChannel.BufferPool);
                bMemStream = true;
            }
            CoreChannel.SerializeBinaryMessage(msg, stream, _includeVersioning);
            if (bMemStream)
                stream.Position = 0;               
        } // SerializeMessage
开发者ID:salim18,项目名称:DemoProject2,代码行数:26,代码来源:BinaryFormatterSinks.cs


注:本文中的ChunkedMemoryStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。