// // RIFFChunk.cs - represents a chunk in a Resource Interchange File Format file // // Author: // Michael Becker // // Copyright (c) 2020 Mike Becker's Software // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . using System; namespace UniversalEditor.ObjectModels.Chunked { /// /// Represents a chunk in a Resource Interchange File Format file. /// public abstract class RIFFChunk : ICloneable { public class RIFFChunkCollection : System.Collections.ObjectModel.Collection { public RIFFChunk this[string Name] { get { RIFFChunk result; foreach (RIFFChunk chunk in this) { if (chunk.ID == Name) { result = chunk; return result; } } result = null; return result; } } public RIFFChunk Add(byte[] Data) { return this.Add("", Data); } public RIFFChunk Add(string Name, byte[] Data) { RIFFDataChunk chunk = new RIFFDataChunk(); chunk.ID = Name; chunk.Data = Data; base.Add(chunk); return chunk; } } private string mvarID = String.Empty; public string ID { get { return mvarID; } set { mvarID = value; } } public abstract object Clone(); public virtual int Size { get { return 4; } } } }