using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using RoadTrain.DrawningObjects; using RoadTrain.MovementStrategy; namespace RoadTrain.Generics { /// /// Класс для хранения коллекции /// internal class RoadTrainGenericStorage { /// /// Словарь (хранилище) /// readonly Dictionary> _trainStorages; /// /// Возвращение списка названий наборов /// public List Keys => _trainStorages.Keys.ToList(); /// /// Ширина окна отрисовки /// private readonly int _pictureWidth; /// /// Высота окна отрисовки /// private readonly int _pictureHeight; /// /// Конструктор /// /// /// public RoadTrainGenericStorage(int pictureWidth, int pictureHeight) { _trainStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } /// /// Добавление набора /// /// Название набора public void AddSet(string name) { if (_trainStorages.ContainsKey(name)) return; _trainStorages[name] = new RoadTrainGenericCollection(_pictureWidth, _pictureHeight); } /// /// Удаление набора /// /// Название набора public void DelSet(string name) { if (_trainStorages.ContainsKey(name)) _trainStorages.Remove(name); return; } /// /// Доступ к набору /// /// /// public RoadTrainGenericCollection? this[string ind] { get { if (_trainStorages.ContainsKey(ind)) return _trainStorages[ind]; return null; } } } }