Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit b9424c69 authored by Harald Martini's avatar Harald Martini
Browse files

Removed IndexedStorage Class

parent 5af40de1
No related branches found
No related tags found
No related merge requests found
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VECTO3GUI2020.Helper
{
//Helper class that can be used to store values of the same type that are identified by a string
public class IndexedStorage<T> where T : IEquatable<T>
{
private Dictionary<string, T> indexedStorageDictionary = new Dictionary<string, T>();
private readonly Action<string> _valueChangedCallback;
public IndexedStorage(Action<string> valueChangedCallback = null)
{
_valueChangedCallback = valueChangedCallback;
}
public T this[string identifier]
{
get
{
if (!indexedStorageDictionary.ContainsKey(identifier))
{
indexedStorageDictionary.Add(identifier, default(T));
}
return indexedStorageDictionary[identifier];
}
set
{
var oldValue = default(T);
if (indexedStorageDictionary.ContainsKey(identifier))
{
oldValue = indexedStorageDictionary[identifier];
}
else
{
indexedStorageDictionary.Add(identifier, default(T));
}
indexedStorageDictionary[identifier] = value;
if (!value.Equals(oldValue))
{
_valueChangedCallback?.Invoke(identifier);
}
}
}
}
}
......@@ -176,7 +176,6 @@
<Compile Include="Helper\Exceptions.cs" />
<Compile Include="Helper\EnumHelper.cs" />
<Compile Include="Helper\FileHelper.cs" />
<Compile Include="Helper\IndexedStorage.cs" />
<Compile Include="Helper\IWindowHelper.cs" />
<Compile Include="Helper\DialogHelper.cs" />
<Compile Include="Helper\VisualTreeHelperExtensions.cs" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment