Enable Nullable
This commit is contained in:
parent
e8c63e9a6e
commit
34033e7947
32 changed files with 403 additions and 275 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
#nullable enable
|
||||
namespace LibationFileManager
|
||||
{
|
||||
public partial class Configuration
|
||||
|
|
@ -9,17 +10,17 @@ namespace LibationFileManager
|
|||
* and be sure to clone it before returning. This allows Configuration to
|
||||
* accurately detect if any of the Dictionary's elements have changed.
|
||||
*/
|
||||
private class EquatableDictionary<TKey, TValue> : Dictionary<TKey, TValue>
|
||||
private class EquatableDictionary<TKey, TValue> : Dictionary<TKey, TValue> where TKey : notnull
|
||||
{
|
||||
public EquatableDictionary() { }
|
||||
public EquatableDictionary(IEnumerable<KeyValuePair<TKey, TValue>> keyValuePairs) : base(keyValuePairs) { }
|
||||
public EquatableDictionary<TKey, TValue> Clone() => new(this);
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is Dictionary<TKey, TValue> dic && Count == dic.Count)
|
||||
{
|
||||
foreach (var pair in this)
|
||||
if (!dic.TryGetValue(pair.Key, out var value) || !pair.Value.Equals(value))
|
||||
if (!dic.TryGetValue(pair.Key, out var value) || pair.Value?.Equals(value) is not true)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue