mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-08 01:05:01 +00:00
feat: Initial commit of IcdBinaryReader
This commit is contained in:
@@ -98,6 +98,7 @@
|
||||
<Compile Include="Extensions\UriExtensions.cs" />
|
||||
<Compile Include="Extensions\UshortExtensions.cs" />
|
||||
<Compile Include="IcdUriBuilder.cs" />
|
||||
<Compile Include="IO\IcdBinaryReader.cs" />
|
||||
<Compile Include="ProcessorUtils.SimplSharp.cs" />
|
||||
<Compile Include="ProcessorUtils.Standard.cs" />
|
||||
<Compile Include="ProgramUtils.SimplSharp.cs" />
|
||||
|
||||
69
ICD.Common.Utils/IO/IcdBinaryReader.cs
Normal file
69
ICD.Common.Utils/IO/IcdBinaryReader.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
#if SIMPLSHARP
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
#else
|
||||
using System.IO;
|
||||
#endif
|
||||
|
||||
namespace ICD.Common.Utils.IO
|
||||
{
|
||||
public sealed class IcdBinaryReader : IDisposable
|
||||
{
|
||||
private readonly BinaryReader m_Reader;
|
||||
|
||||
public BinaryReader WrappedReader { get { return m_Reader; } }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
public IcdBinaryReader(IcdStream stream)
|
||||
: this(new BinaryReader(stream.WrappedStream))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="reader"></param>
|
||||
public IcdBinaryReader(BinaryReader reader)
|
||||
{
|
||||
m_Reader = reader;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
m_Reader.Dispose();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
m_Reader.Close();
|
||||
}
|
||||
|
||||
public ushort ReadUInt16()
|
||||
{
|
||||
return m_Reader.ReadUInt16();
|
||||
}
|
||||
|
||||
public int ReadInt32()
|
||||
{
|
||||
return m_Reader.ReadInt32();
|
||||
}
|
||||
|
||||
public short ReadInt16()
|
||||
{
|
||||
return m_Reader.ReadInt16();
|
||||
}
|
||||
|
||||
public uint ReadUInt32()
|
||||
{
|
||||
return m_Reader.ReadUInt32();
|
||||
}
|
||||
|
||||
public byte[] ReadBytes(short numberOfBytesToRead)
|
||||
{
|
||||
return m_Reader.ReadBytes(numberOfBytesToRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user