PIbd-23_Starostin_I.K._Lain.../lainer/Lainer1/LainersGenericStorage.cs

48 lines
1.6 KiB
C#

using ProjectLainer.DrawningObjects;
using ProjectLainer.MovementStrategy;
namespace ProjectLainer.Generics
{
/// <summary>
/// Класс для хранения коллекции
/// </summary>
internal class LainersGenericStorage
{
readonly Dictionary<string, LainersGenericCollection<DrawingEntity, DrawningObjectLainer>> _lainerStorages;
public List<string> Keys => _lainerStorages.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
public LainersGenericStorage(int pictureWidth, int pictureHeight)
{
_lainerStorages = new Dictionary<string, LainersGenericCollection<DrawingEntity, DrawningObjectLainer>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void AddSet(string name)
{
if (!_lainerStorages.ContainsKey(name))
{
_lainerStorages.Add(name, new LainersGenericCollection<DrawingEntity, DrawningObjectLainer>(_pictureWidth, _pictureHeight));
}
}
public void DelSet(string name)
{
if (_lainerStorages.ContainsKey(name))
{
_lainerStorages.Remove(name);
}
}
public LainersGenericCollection<DrawingEntity, DrawningObjectLainer>? this[string ind]
{
get
{
if (_lainerStorages.ContainsKey(ind))
{
return _lainerStorages[ind];
}
return null;
}
}
}
}