Files
CISTbv-41-PetrovME_Base/ProectMilitaryAircraft/ProectMilitaryAircraft/CollectionGenericObjects/StorageCollection.cs

61 lines
1.4 KiB
C#

using ProectMilitaryAircraft.MovementStrategy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProectMilitaryAircraft.CollectionGenericObjects;
public class StorageCollection<T>
where T : class
{
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
public List<string> Keys => _storages.Keys.ToList();
public StorageCollection()
{
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
}
public void AddCollection (string name, CollectionType collectionType)
{
if (name != null && !_storages.ContainsKey(name))
{
if (collectionType == CollectionType.Massive)
{
_storages.Add(name, new MassiveGenericObjects<T>());
}
if (collectionType == CollectionType.List)
{
_storages.Add(name, new ListgenericObjects<T>());
}
}
}
public void DelCollection (string name)
{
if (!_storages.ContainsKey(name))
{
return;
}
_storages.Remove(name);
}
public ICollectionGenericObjects<T>? this[string name]
{
get
{
if (_storages.ContainsKey(name))
{
return _storages[name];
}
return null;
}
}
}