Class MappedAccessor<T>
Abstract representation of a memory-mapped accessor: Provides random access to unmanaged blocks of memory from
managed code.
Inheritance
System.Object
MappedAccessor<T>
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Common.IO.Mapped
Assembly: Mars.IO.dll
Syntax
public abstract class MappedAccessor<T> : IDisposable
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Improve this Doc View SourceMappedAccessor(MemoryMap, Stream, Int32)
Creates a new mapped accessor.
Declaration
protected MappedAccessor(MemoryMap file, Stream stream, int singleElementSize)
Parameters
Type | Name | Description |
---|---|---|
MemoryMap | file | |
System.IO.Stream | stream | |
System.Int32 | singleElementSize |
Fields
| Improve this Doc View SourceSingleElementSize
The size of a single element if constant.
Declaration
protected readonly int SingleElementSize
Field Value
Type | Description |
---|---|
System.Int32 |
Stream
Holds the stream.
Declaration
protected readonly Stream Stream
Field Value
Type | Description |
---|---|
System.IO.Stream |
Properties
| Improve this Doc View SourceCanWrite
Determines whether the accessory is writable.
Declaration
public virtual bool CanWrite { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Capacity
Gets the capacity of this memory mapped file in bytes.
Declaration
public long Capacity { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
CapacityElements
Gets the capacity of this memory mapped file in the number of structs it can store.
Declaration
public long CapacityElements { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
ElementSize
Gets the size in bytes of one element.
Declaration
public int ElementSize { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
ElementSizeFixed
Returns true if this accessor is for elements of a fixed size.
Declaration
public virtual bool ElementSizeFixed { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceCopyTo(Stream, Int64, Int32, Byte[])
Copies the data in this accessor to the given stream starting at the given position until position + length.
Declaration
public void CopyTo(Stream stream, long position, int length, byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
System.Int64 | position | |
System.Int32 | length | |
System.Byte[] | buffer |
CopyTo(Stream, Int64, Int32)
Copies the data in this accessor to the given stream starting at the given position until position + length.
Declaration
public void CopyTo(Stream stream, long position, int length)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
System.Int64 | position | |
System.Int32 | length |
CopyTo(Stream)
Copies the data in this accessor to the given stream.
Declaration
public void CopyTo(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream |
Dispose()
Disposes of all native resources associated with this object.
Declaration
public virtual void Dispose()
ReadArray(Int64, T[], Int32, Int32)
Reads elements starting at the given position.
Declaration
public virtual int ReadArray(long position, T[] array, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | position | |
T[] | array | |
System.Int32 | offset | |
System.Int32 | count |
Returns
Type | Description |
---|---|
System.Int32 |
ReadFrom(Int64, ref T)
Reads appropriate amount of bytes from the default stream at the given position and returns the structure.
Declaration
public virtual long ReadFrom(long position, ref T structure)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | position | |
T | structure |
Returns
Type | Description |
---|---|
System.Int64 |
ReadFrom(Stream, Int64, ref T)
Reads appropriate amount of bytes from the given stream at the given position and returns the structure.
Declaration
public abstract long ReadFrom(Stream stream, long position, ref T structure)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
System.Int64 | position | |
T | structure |
Returns
Type | Description |
---|---|
System.Int64 |
WriteArray(Int64, T[], Int32, Int32)
Writes an array of elements at the given position.
Declaration
public virtual long WriteArray(long position, T[] array, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | position | |
T[] | array | |
System.Int32 | offset | |
System.Int32 | count |
Returns
Type | Description |
---|---|
System.Int64 |
WriteTo(Int64, ref T)
Converts the structure to bytes and writes them to the stream default.
Declaration
public virtual long WriteTo(long position, ref T structure)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | position | |
T | structure |
Returns
Type | Description |
---|---|
System.Int64 |
WriteTo(Stream, Int64, ref T)
Converts the structure to bytes and writes them to the given stream.
Declaration
public abstract long WriteTo(Stream stream, long position, ref T structure)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
System.Int64 | position | |
T | structure |
Returns
Type | Description |
---|---|
System.Int64 |
Implements
System.IDisposable