本文整理汇总了C#中ChunkedMemoryStream类的典型用法代码示例。如果您正苦于以下问题:C# ChunkedMemoryStream类的具体用法?C# ChunkedMemoryStream怎么用?C# ChunkedMemoryStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChunkedMemoryStream类属于命名空间,在下文中一共展示了ChunkedMemoryStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: SerializeResponse
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack,
IMessage msg, ref ITransportHeaders headers,
out Stream stream)
{
BaseTransportHeaders responseHeaders = new BaseTransportHeaders();
if (headers != null)
{
// copy old headers into new headers
foreach (DictionaryEntry entry in headers)
{
responseHeaders[entry.Key] = entry.Value;
}
}
headers = responseHeaders;
if (_protocol == Protocol.Http)
{
responseHeaders.ContentType = CoreChannel.BinaryMimeType;
}
bool bMemStream = false;
stream = sinkStack.GetResponseStream(msg, headers);
if (stream == null)
{
stream = new ChunkedMemoryStream(CoreChannel.BufferPool);
bMemStream = true;
}
bool bBashUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary();
try
{
CallContext.SetData("__ClientIsClr", true);
CoreChannel.SerializeBinaryMessage(msg, stream, _includeVersioning);
}
finally
{
CallContext.FreeNamedDataSlot("__ClientIsClr");
CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashUrl);
}
if (bMemStream)
stream.Position = 0;
} // SerializeResponse
开发者ID:salim18,项目名称:DemoProject2,代码行数:43,代码来源:BinaryFormatterSinks.cs
示例17: SerializeMessage
} // AsyncProcessMessage
//
// end of IMessageSink implementation
//
// helper function to serialize the message
private void SerializeMessage(IMethodCallMessage mcm,
out ITransportHeaders headers, out Stream stream)
{
BaseTransportHeaders requestHeaders = new BaseTransportHeaders();
headers = requestHeaders;
// add SOAPAction header
MethodBase mb = mcm.MethodBase;
headers["SOAPAction"] =
'"' +
HttpEncodingHelper.EncodeUriAsXLinkHref(
SoapServices.GetSoapActionFromMethodBase(mb)) +
'"';
// add other http soap headers
requestHeaders.ContentType = CoreChannel.SOAPContentType;
if (_channelProtocol == SinkChannelProtocol.Http)
headers["__RequestVerb"] = "POST";
bool bMemStream = false;
stream = _nextSink.GetRequestStream(mcm, headers);
if (stream == null)
{
stream = new ChunkedMemoryStream(CoreChannel.BufferPool);
bMemStream = true;
}
CoreChannel.SerializeSoapMessage(mcm, stream, _includeVersioning);
if (bMemStream)
stream.Position = 0;
} // SerializeMessage
开发者ID:JianwenSun,项目名称:cc,代码行数:39,代码来源:SoapFormatterSinks.cs
示例18: Write_100_bytes_100_times_Read_100_bytes_100_times
public void Write_100_bytes_100_times_Read_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);
}
stream.Position = 0;
byte[] buffer = new byte[bytes.Length];
for(int i = 0; i < 100; ++i) {
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,代码行数:17,代码来源:ChunkedMemoryStreamTest.cs
示例19: GetResponseStream
public Stream GetResponseStream(string statusCode, string reasonPhrase, ITransportHeaders headers)
{
bool flag = false;
bool flag2 = false;
int length = 0;
object obj2 = headers["__HttpStatusCode"];
string str = headers["__HttpReasonPhrase"] as string;
if (obj2 != null)
{
statusCode = obj2.ToString();
}
if (str != null)
{
reasonPhrase = str;
}
if (!this.CanServiceAnotherRequest())
{
headers["Connection"] = "Close";
}
object obj3 = headers["Content-Length"];
if (obj3 != null)
{
flag = true;
if (obj3 is int)
{
length = (int) obj3;
}
else
{
length = Convert.ToInt32(obj3, CultureInfo.InvariantCulture);
}
}
flag2 = this.AllowChunkedResponse && !flag;
if (flag2)
{
headers["Transfer-Encoding"] = "chunked";
}
ChunkedMemoryStream outputStream = new ChunkedMemoryStream(CoreChannel.BufferPool);
base.WriteResponseFirstLine(statusCode, reasonPhrase, outputStream);
base.WriteHeaders(headers, outputStream);
outputStream.WriteTo(base.NetStream);
outputStream.Close();
if (flag2)
{
this._responseStream = new HttpChunkedResponseStream(base.NetStream);
}
else
{
this._responseStream = new HttpFixedLengthResponseStream(base.NetStream, length);
}
return this._responseStream;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:52,代码来源:HttpServerSocketHandler.cs
示例20: SerializeResponse
private void SerializeResponse(IServerResponseChannelSinkStack sinkStack,
IMessage msg, bool bClientIsClr, ref ITransportHeaders headers,
out Stream stream)
{
BaseTransportHeaders responseHeaders = new BaseTransportHeaders();
if (headers != null)
{
// copy old headers into new headers
foreach (DictionaryEntry entry in headers)
{
responseHeaders[entry.Key] = entry.Value;
}
}
headers = responseHeaders;
responseHeaders.ContentType = CoreChannel.SOAPContentType;
if (_protocol == Protocol.Http)
{
// check to see if an exception occurred (requires special status code for HTTP)
IMethodReturnMessage mrm = msg as IMethodReturnMessage;
if ((mrm != null) && (mrm.Exception != null))
{
headers["__HttpStatusCode"] = "500";
headers["__HttpReasonPhrase"] = "Internal Server Error";
}
}
bool bMemStream = false;
stream = sinkStack.GetResponseStream(msg, headers);
if (stream == null)
{
stream = new ChunkedMemoryStream(CoreChannel.BufferPool);
bMemStream = true;
}
bool bBashUrl = CoreChannel.SetupUrlBashingForIisSslIfNecessary();
CallContext.SetData("__ClientIsClr", bClientIsClr);
try
{
CoreChannel.SerializeSoapMessage(msg, stream, _includeVersioning);
}
finally
{
CallContext.FreeNamedDataSlot("__ClientIsClr");
CoreChannel.CleanupUrlBashingForIisSslIfNecessary(bBashUrl);
}
if (bMemStream)
stream.Position = 0;
} // SerializeResponse
开发者ID:JianwenSun,项目名称:cc,代码行数:51,代码来源:SoapFormatterSinks.cs
注:本文中的ChunkedMemoryStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论