Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    NativeStream Class

    Namespace: Stride.Core.IO
    Assembly: Stride.Core.dll

    A System.IO.Stream with additional methods for native read and write operations using System.IntPtr.

    System.Object → System.MarshalByRefObject → System.IO.Stream → NativeStream
    Derived from NativeStream: NativeMemoryStream NativeStreamWrapper LZ4Stream VirtualFileStream

    public abstract class NativeStream : Stream, IDisposable
    Name Description
    Fields
    nativeStreamBuffer
    NativeStreamBufferSize
    Methods
    Read(IntPtr, Int32)

    Reads a block of bytes from the stream and writes the data in a given buffer.

    ReadUInt16()
    ReadUInt32()
    ReadUInt64()
    Write(IntPtr, Int32)

    Writes a block of bytes to this stream using data from a buffer.

    Write(UInt16)
    Write(UInt32)
    Write(UInt64)
    | Improve this Doc View Source

    Fields


    nativeStreamBuffer

    protected byte[] nativeStreamBuffer
    Field Value
    Type Description
    System.Byte[]

    NativeStreamBufferSize

    protected const int NativeStreamBufferSize = 1024
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Methods


    Read(IntPtr, Int32)

    Reads a block of bytes from the stream and writes the data in a given buffer.

    public virtual int Read(IntPtr buffer, int count)
    Parameters
    Type Name Description
    System.IntPtr buffer

    When this method returns, contains the specified buffer with the values between 0 and (count - 1) replaced by the bytes read from the current source.

    System.Int32 count

    The maximum number of bytes to read.

    Returns
    Type Description
    System.Int32

    The total number of bytes read into the buffer. This might be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached.

    Exceptions
    Type Condition
    System.ArgumentNullException

    array is null.


    ReadUInt16()

    public virtual ushort ReadUInt16()
    Returns
    Type Description
    System.UInt16

    ReadUInt32()

    public virtual uint ReadUInt32()
    Returns
    Type Description
    System.UInt32

    ReadUInt64()

    public virtual ulong ReadUInt64()
    Returns
    Type Description
    System.UInt64

    Write(IntPtr, Int32)

    Writes a block of bytes to this stream using data from a buffer.

    public virtual void Write(IntPtr buffer, int count)
    Parameters
    Type Name Description
    System.IntPtr buffer

    The buffer containing data to write to the stream.

    System.Int32 count

    The number of bytes to be written to the current stream.


    Write(UInt16)

    public virtual void Write(ushort i)
    Parameters
    Type Name Description
    System.UInt16 i

    Write(UInt32)

    public virtual void Write(uint i)
    Parameters
    Type Name Description
    System.UInt32 i

    Write(UInt64)

    public virtual void Write(ulong i)
    Parameters
    Type Name Description
    System.UInt64 i

    Inherited Members

    System.IO.Stream.Null
    System.IO.Stream.BeginRead(System.Byte[], System.Int32, System.Int32, System.AsyncCallback, System.Object)
    System.IO.Stream.BeginWrite(System.Byte[], System.Int32, System.Int32, System.AsyncCallback, System.Object)
    System.IO.Stream.Close()
    System.IO.Stream.CopyTo(System.IO.Stream)
    System.IO.Stream.CopyTo(System.IO.Stream, System.Int32)
    System.IO.Stream.CopyToAsync(System.IO.Stream)
    System.IO.Stream.CopyToAsync(System.IO.Stream, System.Int32)
    System.IO.Stream.CopyToAsync(System.IO.Stream, System.Int32, System.Threading.CancellationToken)
    System.IO.Stream.CreateWaitHandle()
    System.IO.Stream.Dispose()
    System.IO.Stream.Dispose(System.Boolean)
    System.IO.Stream.EndRead(System.IAsyncResult)
    System.IO.Stream.EndWrite(System.IAsyncResult)
    System.IO.Stream.Flush()
    System.IO.Stream.FlushAsync()
    System.IO.Stream.FlushAsync(System.Threading.CancellationToken)
    System.IO.Stream.ObjectInvariant()
    System.IO.Stream.Read(System.Byte[], System.Int32, System.Int32)
    System.IO.Stream.ReadAsync(System.Byte[], System.Int32, System.Int32)
    System.IO.Stream.ReadAsync(System.Byte[], System.Int32, System.Int32, System.Threading.CancellationToken)
    System.IO.Stream.ReadByte()
    System.IO.Stream.Seek(System.Int64, System.IO.SeekOrigin)
    System.IO.Stream.SetLength(System.Int64)
    System.IO.Stream.Synchronized(System.IO.Stream)
    System.IO.Stream.Write(System.Byte[], System.Int32, System.Int32)
    System.IO.Stream.WriteAsync(System.Byte[], System.Int32, System.Int32)
    System.IO.Stream.WriteAsync(System.Byte[], System.Int32, System.Int32, System.Threading.CancellationToken)
    System.IO.Stream.WriteByte(System.Byte)
    System.IO.Stream.CanRead
    System.IO.Stream.CanSeek
    System.IO.Stream.CanTimeout
    System.IO.Stream.CanWrite
    System.IO.Stream.Length
    System.IO.Stream.Position
    System.IO.Stream.ReadTimeout
    System.IO.Stream.WriteTimeout
    System.MarshalByRefObject.GetLifetimeService()
    System.MarshalByRefObject.InitializeLifetimeService()
    System.MarshalByRefObject.MemberwiseClone(System.Boolean)

    Extension Methods

    SocketExtensions.ReadAllAsync(Stream, Byte[], Int32, Int32)
    SocketExtensions.WriteInt32Async(Stream, Int32)
    SocketExtensions.ReadInt32Async(Stream)
    SocketExtensions.WriteInt16Async(Stream, Int16)
    SocketExtensions.ReadInt16Async(Stream)
    SocketExtensions.Write7BitEncodedInt(Stream, Int32)
    SocketExtensions.Read7BitEncodedInt(Stream)
    SocketExtensions.WriteStringAsync(Stream, String)
    SocketExtensions.ReadStringAsync(Stream)
    SocketExtensions.WriteGuidAsync(Stream, Guid)
    SocketExtensions.ReadGuidAsync(Stream)
    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    NativeStreamExtensions.ToNativeStream(Stream)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation