Добавьте файлы проекта.
This commit is contained in:
42
CodeBase/Warehouse/ChunkWarehouse.cs
Normal file
42
CodeBase/Warehouse/ChunkWarehouse.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using CodeBase.Models;
|
||||
|
||||
namespace CodeBase.Warehouse
|
||||
{
|
||||
public class ChunkWarehouse
|
||||
{
|
||||
public Dictionary<string, List<CodeChunk>> dictionary;
|
||||
|
||||
public ChunkWarehouse()
|
||||
{
|
||||
this.dictionary = new();
|
||||
}
|
||||
|
||||
public void UpsertDictionary(string name, List<CodeChunk> chunks)
|
||||
{
|
||||
if (dictionary.ContainsKey(name))
|
||||
{
|
||||
dictionary[name] = chunks;
|
||||
}
|
||||
else dictionary.TryAdd(name, chunks);
|
||||
}
|
||||
|
||||
public void DeleteElement(string name)
|
||||
{
|
||||
dictionary.Remove(name);
|
||||
}
|
||||
|
||||
public List<CodeChunk> GetChunks(string name)
|
||||
{
|
||||
if(dictionary.TryGetValue(name, out var chunks))
|
||||
{
|
||||
return chunks;
|
||||
}
|
||||
throw new Exception("Такого проекта нет");
|
||||
}
|
||||
|
||||
public void ClearDictionary()
|
||||
{
|
||||
dictionary.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user