Abstract base class for ITextStream implementations.
abstract class
|
TextStreamBase
|
extends
|
Disposable
|
||
implements
|
ITextStream
|
||||
base of
|
MemoryTextStream
|
Does this object support read access?
public
abstract
property
|
CanRead
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
object
supports
reading,
false
if
not. |
||
implements
|
ICanReadWrite.CanRead
|
Does this binary object support write access?
public
abstract
property
|
CanWrite
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
object
supports
writing,
false
if
not. |
||
implements
|
ICanReadWrite.CanWrite
|
Returns the lifecycle state of this object.
public
virtual
property
|
LifecycleState
{
get
}
|
||
type
|
LifecycleState
|
||
value
|
The lifecycle state. | ||
inherited
|
Disposable.LifecycleState
|
Returns a Path object that represents the file path this object is associated with.
public
abstract
property
|
PathInfo
{
get
}
|
||
type
|
Path
|
||
value
|
|
The path info. | |
implements
|
IPathInfo.PathInfo
|
Remarks:
Objects that do not have a meaningful file path association simply return Unknown.
Acquires a strong reference to this disposable object.
[OwnerReturn, ThreadSafe]
|
||||
public
method
|
AcquireTry
()
|
|||
type
|
IDisposable
|
|||
returns
|
this
if
a
new
strong
reference
has
been
acquired,
null
if
this
object
is
already
being
disposed.
|
|||
inherited
|
Disposable.AcquireTry
|
Remarks:
The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.
This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.
Copies all remaining data in the given object to this object.
public
virtual
method
|
CopyFrom
(ITextStream stream)
|
||
params
|
stream
|
[not-null]
|
The object. |
implements
|
ICopyable.CopyFrom
|
Copies all remaining data in this object to the given object.
public
virtual
method
|
CopyTo
(ITextStream stream)
|
||
params
|
stream
|
[not-null]
|
The object. |
implements
|
ICopyable.CopyTo
|
Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.
[Dispose, OwnerThis, ThreadSafe]
|
||||
public
method
|
Dispose
()
|
|||
inherited
|
Disposable.Dispose
|
Remarks:
The Dispose method silently returns if the object has already been disposed.
Flushes all cached data.
public
abstract
method
|
Flush
()
|
||
implements
|
IFlushable.Flush
|
Remarks:
Performing a flush may result in I/O work. Depending on the semantics of the implementing class, this work may need to be wrapped in special Begin / End method calls. See the documentation of the implementing classes for details.
In case this object represents a read-only resource, calling the Flush method has no effect.
Reads a number of characters from the stream.
public
method
|
Read
(char[] chars,
int32 offset = 0,
int32 count = -1)
|
||
type
|
int32
|
||
params
|
chars
|
[not-null]
|
The buffer where the read characters will be stored. |
offset
|
[0..chars.Length]
|
Offset
into
chars.
Defaults
to
0 .
|
|
count
|
[-1..chars.Length-offset]
|
Number
of
characters
to
read.
If
-1 ,
characters
will
be
read
up
to
the
end
of
chars.
Defaults
to
-1 .
|
|
returns
|
|
The
number
of
characters
that
have
been
read
into
chars.
A
value
of
0
indicates
that
the
end
of
the
stream
has
been
reached
(assuming
that
the
given
count
was
greater
than
zero).
|
|
implements
|
ITextStream.Read
|
Remarks:
The number of characters that are read from the stream may be less than the given count, for any reason.
Exceptions:
false
.Reads a single character from the stream.
public
virtual
method
|
ReadChar
()
|
||
type
|
char
|
||
returns
|
The read character. | ||
implements
|
ITextStream.ReadChar
|
Exceptions:
false
.Reads all remaining characters from this stream and disposes this stream afterwards.
[OwnerThis]
|
||||
public
virtual
method
|
ReadToEnd
()
|
|||
type
|
string
|
|||
returns
|
|
The read string. | ||
implements
|
ITextStream.ReadToEnd
|
Skips the next characters in the stream.
public
abstract
method
|
Skip
(int64 count)
|
||
params
|
count
|
[>=0]
|
The number of characters to skip. |
implements
|
ITextStream.Skip
|
Reads a single character from the stream.
public
abstract
method
|
TryReadChar
()
|
||
type
|
int32
|
||
returns
|
|
The
read
character
or
-1
if
the
end
of
the
stream
has
been
reached.
|
|
implements
|
ITextStream.TryReadChar
|
Exceptions:
false
.Writes a number of characters to the stream.
public
method
|
Write
(string chars)
|
||
params
|
chars
|
[not-null]
|
The characters to write. |
implements
|
ITextStream.Write
|
Exceptions:
false
.Writes a number of characters to the stream.
public
method
|
Write
(char[] chars)
|
||
params
|
chars
|
[not-null]
|
The characters to write. |
implements
|
ITextStream.Write
|
Exceptions:
false
.Writes a number of characters to the stream.
public
abstract
method
|
Write
(string chars,
int32 offset,
int32 count)
|
||
params
|
chars
|
[not-null]
|
The characters to write. |
offset
|
[>=0]
|
Offset into chars. | |
count
|
[>=0]
|
Number of characters to write. | |
implements
|
ITextStream.Write
|
Exceptions:
false
.Writes a number of characters to the stream.
public
abstract
method
|
Write
(char[] chars,
int32 offset,
int32 count)
|
||
params
|
chars
|
[not-null]
|
The characters to write. |
offset
|
[>=0]
|
Offset into chars. | |
count
|
[>=0]
|
Number of characters to write. | |
implements
|
ITextStream.Write
|
Exceptions:
false
.Writes a single characters to the stream.
public
abstract
method
|
WriteChar
(char value)
|
||
params
|
value
|
The character to write. | |
implements
|
ITextStream.WriteChar
|
Exceptions:
false
.Disposes the managed resources held by a concrete subclass. This method will be called at most once per subclass.
protected
virtual
method
|
DisposeManaged
()
|
||
inherited
|
Disposable.DisposeManaged
|
Remarks:
This method will only be called when a disposable object is explicitly destroyed by user code calling the Dispose method. It will not be called when the object is collected as garbage by the system.
Overriding methods must call the DisposeManaged method of their base class. The base call should be the last statement.
The DisposeManaged method is called before the DisposeUnmanaged method.
Disposes the unmanaged resources held by a concrete subclass. This method will be called exactly once per subclass.
protected
virtual
method
|
DisposeUnmanaged
()
|
||
inherited
|
Disposable.DisposeUnmanaged
|
Remarks:
Overriding methods must call the DisposeUnmanaged method of their base class. The base call should be the last statement.
The DisposeUnmanaged method is called after the DisposeManaged method.
protected
abstract
method
|
DoRead
(char[] chars,
int32 offset,
int32 count)
|
||
type
|
int32
|
||
params
|
chars
|
||
offset
|
|||
count
|