MemoryMappedViewAccessor 類別

定義

表示記憶體對應檔的隨機存取檢視。Represents a randomly accessed view of a memory-mapped file.

public ref class MemoryMappedViewAccessor sealed : System::IO::UnmanagedMemoryAccessor
public sealed class MemoryMappedViewAccessor : System.IO.UnmanagedMemoryAccessor
type MemoryMappedViewAccessor = class
    inherit UnmanagedMemoryAccessor
Public NotInheritable Class MemoryMappedViewAccessor
Inherits UnmanagedMemoryAccessor
繼承
MemoryMappedViewAccessor

範例

下列範例MemoryMappedViewAccessor會從大型記憶體對應檔案取得, 以供編輯。The following example obtains a MemoryMappedViewAccessor from a large memory-mapped file for editing.

這個程式碼範例是針對MemoryMappedFile類別提供之較大範例的一部分。This code example is part of a larger example provided for the MemoryMappedFile class.

// Create a random access view, from the 256th megabyte (the offset)
// to the 768th megabyte (the offset plus length).
using (var accessor = mmf.CreateViewAccessor(offset, length))
{
    int colorSize = Marshal.SizeOf(typeof(MyColor));
    MyColor color;

    // Make changes to the view.
    for (long i = 0; i < length; i += colorSize)
    {
        accessor.Read(i, out color);
        color.Brighten(10);
        accessor.Write(i, ref color);
    }
}
' Create a random access view, from the 256th megabyte (the offset)
' to the 768th megabyte (the offset plus length).
Using accessor = mmf.CreateViewAccessor(offset, length)
    Dim colorSize As Integer = Marshal.SizeOf(GetType(MyColor))
    Dim color As MyColor
    Dim i As Long = 0

    ' Make changes to the view.
    Do While (i < length)
        accessor.Read(i, color)
        color.Brighten(10)
        accessor.Write(i, color)
        i += colorSize
    Loop
End Using

備註

使用MemoryMappedFile物件CreateViewAccessor的方法來取得此視圖。Use the CreateViewAccessor method of a MemoryMappedFile object to get this view.

屬性

CanRead

判斷存取子是否可讀取。Determines whether the accessor is readable.

(繼承來源 UnmanagedMemoryAccessor)
CanWrite

判斷存取子是否可寫入。Determines whether the accessory is writable.

(繼承來源 UnmanagedMemoryAccessor)
Capacity

取得存取子的容量。Gets the capacity of the accessor.

(繼承來源 UnmanagedMemoryAccessor)
IsOpen

判斷存取子目前是否由處理程序開啟。Determines whether the accessor is currently open by a process.

(繼承來源 UnmanagedMemoryAccessor)
PointerOffset

取得這個檢視起始位置與記憶體對應檔案開頭的位移位元組數目。Gets the number of bytes by which the starting position of this view is offset from the beginning of the memory-mapped file.

SafeMemoryMappedViewHandle

取得記憶體對應檔檢視的控制代碼。Gets a handle to the view of a memory-mapped file.

方法

Dispose()

釋放 UnmanagedMemoryAccessor 所使用的所有資源。Releases all resources used by the UnmanagedMemoryAccessor.

(繼承來源 UnmanagedMemoryAccessor)
Dispose(Boolean)

釋放 UnmanagedMemoryAccessor 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the UnmanagedMemoryAccessor and optionally releases the managed resources.

(繼承來源 UnmanagedMemoryAccessor)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Flush()

清除這個檢視的所有緩衝區,並造成任何緩衝資料都寫入基礎檔案。Clears all buffers for this view and causes any buffered data to be written to the underlying file.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
Initialize(SafeBuffer, Int64, Int64, FileAccess)

設定存取子的初始值。Sets the initial values for the accessor.

(繼承來源 UnmanagedMemoryAccessor)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
Read<T>(Int64, T)

將型別 T 的結構從存取子讀入至提供的參考。Reads a structure of type T from the accessor into a provided reference.

(繼承來源 UnmanagedMemoryAccessor)
ReadArray<T>(Int64, T[], Int32, Int32)

將型別 T 的結構從存取子讀入至型別 T 的陣列。Reads structures of type T from the accessor into an array of type T.

(繼承來源 UnmanagedMemoryAccessor)
ReadBoolean(Int64)

從存取子讀取布林值。Reads a Boolean value from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadByte(Int64)

從存取子讀取位元組值。Reads a byte value from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadChar(Int64)

從存取子讀取位元組值。Reads a character from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadDecimal(Int64)

從存取子讀取位元組值。Reads a decimal value from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadDouble(Int64)

從存取子讀取雙精確度浮點數值。Reads a double-precision floating-point value from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadInt16(Int64)

從存取子讀取 16 位元整數。Reads a 16-bit integer from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadInt32(Int64)

從存取子讀取 32 位元整數。Reads a 32-bit integer from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadInt64(Int64)

從存取子讀取 64 位元整數。Reads a 64-bit integer from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadSByte(Int64)

從存取子讀取 8 位元帶正負號的整數。Reads an 8-bit signed integer from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadSingle(Int64)

從存取子讀取單精確度浮點數值。Reads a single-precision floating-point value from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadUInt16(Int64)

從存取子讀取不帶正負號的 16 位元整數。Reads an unsigned 16-bit integer from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadUInt32(Int64)

從存取子讀取不帶正負號的 32 位元整數。Reads an unsigned 32-bit integer from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ReadUInt64(Int64)

從存取子讀取不帶正負號的 64 位元整數。Reads an unsigned 64-bit integer from the accessor.

(繼承來源 UnmanagedMemoryAccessor)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
Write(Int64, Boolean)

將布林值寫入至存取子。Writes a Boolean value into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, Byte)

將位元組值寫入至存取子。Writes a byte value into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, Char)

將字元寫入至存取子。Writes a character into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, Decimal)

將十進位值寫入至存取子。Writes a decimal value into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, Double)

Double 值寫入至存取子。Writes a Double value into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, Int16)

將 16 位元整數寫入至存取子。Writes a 16-bit integer into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, Int32)

將 32 位元整數寫入至存取子。Writes a 32-bit integer into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, Int64)

將 64 位元整數寫入至存取子。Writes a 64-bit integer into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, SByte)

將 8 位元整數寫入至存取子。Writes an 8-bit integer into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, Single)

Single 寫入至存取子。Writes a Single into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, UInt16)

將不帶正負號的 16 位元整數寫入至存取子。Writes an unsigned 16-bit integer into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, UInt32)

將不帶正負號的 32 位元整數寫入至存取子。Writes an unsigned 32-bit integer into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write(Int64, UInt64)

將不帶正負號的 64 位元整數寫入至存取子。Writes an unsigned 64-bit integer into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
Write<T>(Int64, T)

將結構寫入至存取子。Writes a structure into the accessor.

(繼承來源 UnmanagedMemoryAccessor)
WriteArray<T>(Int64, T[], Int32, Int32)

將結構從型別 T 的陣列寫入至存取子。Writes structures from an array of type T into the accessor.

(繼承來源 UnmanagedMemoryAccessor)

適用於

另請參閱