mirror of
https://github.com/ckaczor/WorldClockStatusWindow.git
synced 2026-01-13 17:23:18 -05:00
Add time zones settings panel
This commit is contained in:
42
DataErrorDictionary.cs
Normal file
42
DataErrorDictionary.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace WorldClockStatusWindow;
|
||||
|
||||
internal class DataErrorDictionary : Dictionary<string, List<string>>
|
||||
{
|
||||
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
|
||||
|
||||
private void OnErrorsChanged(string propertyName)
|
||||
{
|
||||
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public IEnumerable GetErrors(string propertyName)
|
||||
{
|
||||
return TryGetValue(propertyName, out var value) ? value : null;
|
||||
}
|
||||
|
||||
public void AddError(string propertyName, string error)
|
||||
{
|
||||
if (!ContainsKey(propertyName))
|
||||
this[propertyName] = [];
|
||||
|
||||
if (this[propertyName].Contains(error))
|
||||
return;
|
||||
|
||||
this[propertyName].Add(error);
|
||||
OnErrorsChanged(propertyName);
|
||||
}
|
||||
|
||||
public void ClearErrors(string propertyName)
|
||||
{
|
||||
if (!ContainsKey(propertyName))
|
||||
return;
|
||||
|
||||
Remove(propertyName);
|
||||
OnErrorsChanged(propertyName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user