/// <summary> /// Returns data by Id /// </summary> public virtual IStorable GetDataById(int id) { var type = DB.GetTypeById(id); foreach (var data in Data) { if (data.GetType() == type) { return(data); } } return(null); }
public virtual void Load(BinaryReader br) { br.ReadByte();//version FullPath = br.ReadString(); State = (AudioState)br.ReadByte(); var count = br.ReadInt32(); Data = new List <IStorable>(); for (int i = 0; i < count; i++) { var id = br.ReadInt32(); //read id ob type var type = DB.GetTypeById(id); //get type var data = (IStorable)type.GetConstructor(new Type[0]).Invoke(null); //create object data.Load(br); //object loads himself from stream Data.Add(data); } }