/// <summary>Read a <typeparamref name="TEnum"/> value from a stream</summary> /// <param name="s">Stream to read from</param> /// <param name="value">Enum value read from the stream</param> /// <remarks> /// Uses <typeparamref name="TEnum"/>'s underlying <see cref="TypeCode"/> to /// decide how big of a numeric type to read from the stream. /// </remarks> public static void Read(IO.EndianReader s, out TEnum value) { //Contract.Requires(s != null); uint stream_value; switch (kUnderlyingType) { case TypeCode.Byte: case TypeCode.SByte: stream_value = s.ReadByte(); break; case TypeCode.Int16: case TypeCode.UInt16: stream_value = s.ReadUInt16(); break; case TypeCode.Int32: case TypeCode.UInt32: stream_value = s.ReadUInt32(); break; default: throw new Debug.Exceptions.UnreachableException(); } value = Reflection.EnumValue <TEnum> .FromUInt32(stream_value); }
/// <summary> /// Stream the contents of the file from a buffer /// </summary> /// <param name="s"></param> public abstract void Read(EndianReader s);
public void Read(IO.EndianReader stream) { throw new Exception("The method or operation is not implemented."); }
/// <summary> /// Extension method for <see cref="BlamVersion"/> for streaming an instance from a stream /// </summary> /// <param name="version"></param> /// <param name="s"></param> public static void Read(this BlamVersion version, IO.EndianReader s) { version = (BlamVersion)s.ReadUInt16(); }
/// <summary> /// Extension method for <see cref="BlamPlatform"/> for streaming an instance to a stream /// </summary> /// <param name="platform"></param> /// <param name="s"></param> public static void Read(this BlamPlatform platform, IO.EndianReader s) { platform = (BlamPlatform)s.ReadUInt16(); }
/// <summary> /// Extension method for <see cref="BlamBuild"/> for streaming an instance from a stream /// </summary> /// <param name="build"></param> /// <param name="s"></param> public static void Read(this BlamBuild build, IO.EndianReader s) { build = (BlamBuild)s.ReadUInt16(); }