C# 클래스 Revenj.Utility.ChunkedMemoryStream

In memory stream with 8192 blocks to avoid LOH issues. Since .NET places objects larger that 85000 bytes into LOH, avoid it as much as possible by using list of smaller blocks.
상속: Stream
파일 보기 프로젝트 열기: ngs-doo/revenj 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
CharBuffer char[]
SmallBuffer char[]

공개 메소드들

메소드 설명
ChunkedMemoryStream ( Stream another ) : System

Create in memory stream based on another stream. Provided stream will not be disposed.

ChunkedMemoryStream ( Stream another, bool dispose, bool reset ) : System

Create in memory stream based on another stream. Specify whether should provided stream be disposed after copying.

Close ( ) : void

Close current stream. Stream will be added to pool if required. Doesn't release allocated buffers

CopyTo ( ChunkedMemoryStream other ) : void
CopyTo ( Stream stream ) : void

Optimized version of copy to stream

CopyTo ( byte target, int offset ) : void

Copy stream to target buffer

Create ( ) : ChunkedMemoryStream

Create or get a new instance of memory stream Stream is bound to thread and must be released from the same thread

Equals ( Stream another ) : bool

Compare two streams. Length and content will be compared.

Flush ( ) : void

Flush stream. Does nothing.

GetReader ( ) : TextReader

Reuse same text reader on this stream.

GetWriter ( ) : TextWriter

Reuse same text writer on this stream.

Matches ( byte compare ) : bool

Check if stream starts with provided byte[] and matches it's length Provided byte[] must be smaller than 8192 bytes

Read ( byte buffer, int offset, int count ) : int

Read buffer from the stream. Can return less then specified count if remaining block size is less than specified count

ReadByte ( ) : int

Read a single byte

Reset ( ) : void

Set length and position to 0

Seek ( long offset, SeekOrigin origin ) : long

Seek to position in the stream.

Send ( Socket socket ) : void

Send entire stream to provided socket.

SetLength ( long value ) : void

Set new length of the stream. Adjusts the current position if new length is larger then it.

Static ( ) : ChunkedMemoryStream

Create reusable stream. Disposing the stream only has the effect of resetting it.

ToBase64Stream ( ) : Stream

Convert stream to Base 64 String representation in stream.

ToBase64Writer ( TextWriter sw ) : void

Convert stream to Base 64 String representation in the provided writer.

ToPostgresBytea ( TextWriter sw ) : void

Convert stream to Postgres representation of bytea

ToString ( ) : string

Show content of the stream as string

UseBufferedReader ( TextReader reader ) : BufferedTextReader

Reuse buffered text reader associated with this stream. Provide input text reader as data source. Buffered text reader will be initialized with provided input

UseBufferedReader ( string value ) : BufferedTextReader

Reuse buffered text reader associated with this stream. Provide input string as data source. Buffered text reader will be initialized with provided input

Write ( byte buffer, int offset, int count ) : void

Write buffer to stream. Advances current position by count. Increases length if necessary. New blocks will be added as required. It's best to use buffer of size 8192

WriteByte ( byte value ) : void

Write byte to stream. Advances current position by one. Adds a new block if necessary.

보호된 메소드들

메소드 설명
Dispose ( bool disposing ) : void

Dispose current stream. Stream will be added to pool if required. Used to reset position and length. Doesn't release allocated buffers

비공개 메소드들

메소드 설명
ChunkedMemoryStream ( ) : System
ChunkedMemoryStream ( byte block ) : System

메소드 상세

ChunkedMemoryStream() 공개 메소드

Create in memory stream based on another stream. Provided stream will not be disposed.
public ChunkedMemoryStream ( Stream another ) : System
another Stream stream to copy
리턴 System

ChunkedMemoryStream() 공개 메소드

Create in memory stream based on another stream. Specify whether should provided stream be disposed after copying.
public ChunkedMemoryStream ( Stream another, bool dispose, bool reset ) : System
another Stream stream to copy
dispose bool dispose provided stream
reset bool reset provided stream to original position
리턴 System

Close() 공개 메소드

Close current stream. Stream will be added to pool if required. Doesn't release allocated buffers
public Close ( ) : void
리턴 void

CopyTo() 공개 메소드

public CopyTo ( ChunkedMemoryStream other ) : void
other ChunkedMemoryStream
리턴 void

CopyTo() 공개 메소드

Optimized version of copy to stream
public CopyTo ( Stream stream ) : void
stream Stream destination stream
리턴 void

CopyTo() 공개 메소드

Copy stream to target buffer
public CopyTo ( byte target, int offset ) : void
target byte target array buffer
offset int start at offset
리턴 void

Create() 공개 정적인 메소드

Create or get a new instance of memory stream Stream is bound to thread and must be released from the same thread
public static Create ( ) : ChunkedMemoryStream
리턴 ChunkedMemoryStream

Dispose() 보호된 메소드

Dispose current stream. Stream will be added to pool if required. Used to reset position and length. Doesn't release allocated buffers
protected Dispose ( bool disposing ) : void
disposing bool
리턴 void

Equals() 공개 메소드

Compare two streams. Length and content will be compared.
public Equals ( Stream another ) : bool
another Stream stream to compare
리턴 bool

Flush() 공개 메소드

Flush stream. Does nothing.
public Flush ( ) : void
리턴 void

GetReader() 공개 메소드

Reuse same text reader on this stream.
public GetReader ( ) : TextReader
리턴 TextReader

GetWriter() 공개 메소드

Reuse same text writer on this stream.
public GetWriter ( ) : TextWriter
리턴 System.IO.TextWriter

Matches() 공개 메소드

Check if stream starts with provided byte[] and matches it's length Provided byte[] must be smaller than 8192 bytes
public Matches ( byte compare ) : bool
compare byte
리턴 bool

Read() 공개 메소드

Read buffer from the stream. Can return less then specified count if remaining block size is less than specified count
public Read ( byte buffer, int offset, int count ) : int
buffer byte copy to buffer
offset int offset in the buffer
count int maximum size to read
리턴 int

ReadByte() 공개 메소드

Read a single byte
public ReadByte ( ) : int
리턴 int

Reset() 공개 메소드

Set length and position to 0
public Reset ( ) : void
리턴 void

Seek() 공개 메소드

Seek to position in the stream.
public Seek ( long offset, SeekOrigin origin ) : long
offset long offset at stream
origin SeekOrigin position type
리턴 long

Send() 공개 메소드

Send entire stream to provided socket.
public Send ( Socket socket ) : void
socket System.Net.Sockets.Socket where to send
리턴 void

SetLength() 공개 메소드

Set new length of the stream. Adjusts the current position if new length is larger then it.
public SetLength ( long value ) : void
value long new length
리턴 void

Static() 공개 정적인 메소드

Create reusable stream. Disposing the stream only has the effect of resetting it.
public static Static ( ) : ChunkedMemoryStream
리턴 ChunkedMemoryStream

ToBase64Stream() 공개 메소드

Convert stream to Base 64 String representation in stream.
public ToBase64Stream ( ) : Stream
리턴 Stream

ToBase64Writer() 공개 메소드

Convert stream to Base 64 String representation in the provided writer.
public ToBase64Writer ( TextWriter sw ) : void
sw System.IO.TextWriter
리턴 void

ToPostgresBytea() 공개 메소드

Convert stream to Postgres representation of bytea
public ToPostgresBytea ( TextWriter sw ) : void
sw System.IO.TextWriter
리턴 void

ToString() 공개 메소드

Show content of the stream as string
public ToString ( ) : string
리턴 string

UseBufferedReader() 공개 메소드

Reuse buffered text reader associated with this stream. Provide input text reader as data source. Buffered text reader will be initialized with provided input
public UseBufferedReader ( TextReader reader ) : BufferedTextReader
reader TextReader input for processing
리턴 BufferedTextReader

UseBufferedReader() 공개 메소드

Reuse buffered text reader associated with this stream. Provide input string as data source. Buffered text reader will be initialized with provided input
public UseBufferedReader ( string value ) : BufferedTextReader
value string input for processing
리턴 BufferedTextReader

Write() 공개 메소드

Write buffer to stream. Advances current position by count. Increases length if necessary. New blocks will be added as required. It's best to use buffer of size 8192
public Write ( byte buffer, int offset, int count ) : void
buffer byte provided bytes
offset int offset in bytes
count int total length
리턴 void

WriteByte() 공개 메소드

Write byte to stream. Advances current position by one. Adds a new block if necessary.
public WriteByte ( byte value ) : void
value byte byte to write
리턴 void

프로퍼티 상세

CharBuffer 공개적으로 프로퍼티

Temporary char buffer for reuse (8192*4/3 + 2 chars)
public char[] CharBuffer
리턴 char[]

SmallBuffer 공개적으로 프로퍼티

Temporary small char buffer for reuse (64 chars)
public char[] SmallBuffer
리턴 char[]