feat: Initial commit of IcdBinaryReader

This commit is contained in:
Chris Cameron
2018-06-06 10:00:24 -04:00
parent 6fa3cc03ad
commit c306dd6eb9
2 changed files with 70 additions and 0 deletions

View File

@@ -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" />

View 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);
}
}
}