/// <summary> /// Creates a new instance of <see cref="Resource"/> with specified <see cref="TinyResourceKind"/> and existing data. /// </summary> /// <param name="kind"></param> /// <param name="data"></param> public Resource(TinyResourceKind kind, byte[] data) { if (data == null) { throw new ArgumentNullException("data"); } _header = new ResourceHeader(kind); _header.Size = (uint)data.Length; _data = data; }
/// <summary> /// Deserializes this structure from binary data. /// </summary> /// <param name="reader">The <see cref="BinaryReader"/> to read the data from.</param> /// <param name="fileHeader">Optional <see cref="FileHeader"/> that specifies padding to skip after reading.</param> /// <exception cref="ArgumentNullException"><paramref name="reader"/> is null.</exception> public virtual void ReadFrom(BinaryReader reader, FileHeader fileHeader = null) { if (reader == null) { throw new ArgumentNullException(); } _id = reader.ReadInt16(); _kind = (TinyResourceKind)reader.ReadByte(); _flags = (byte)reader.ReadByte(); _size = reader.ReadUInt32(); if (fileHeader != null) { reader.ReadBytes((int)(fileHeader.SizeOfResourceHeader - RequiredSize)); } }
/// <summary> /// Creates a new instance of the <see cref="ResourceHeader"/> class with specified <see cref="TinyResourceKind"/> and ID. /// </summary> /// <param name="kind">The <see cref="TinyResourceKind"/> of the resource.</param> /// <param name="id">The ID of the resource.</param> public ResourceHeader(TinyResourceKind kind, short id) { _kind = kind; _id = id; }
/// <summary> /// Creates a new instance of the <see cref="ResourceHeader"/> class with specified <see cref="TinyResourceKind"/>. /// </summary> /// <param name="kind">The <see cref="TinyResourceKind"/> of the resource.</param> public ResourceHeader(TinyResourceKind kind) : this(kind, 0) { }