1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00

fixed GenericDataHolder nre

This commit is contained in:
Ellpeck 2020-04-26 02:19:58 +02:00
parent 18c79bbf3a
commit 52328cc18d

View file

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
namespace MLEM.Misc {
@ -6,11 +7,12 @@ namespace MLEM.Misc {
private Dictionary<string, object> data;
public void SetData(string key, object data) {
if (this.data == null)
this.data = new Dictionary<string, object>();
if (data == default) {
this.data.Remove(key);
if (this.data != null)
this.data.Remove(key);
} else {
if (this.data == null)
this.data = new Dictionary<string, object>();
this.data[key] = data;
}
}
@ -22,6 +24,8 @@ namespace MLEM.Misc {
}
public IReadOnlyCollection<string> GetDataKeys() {
if (this.data == null)
return Array.Empty<string>();
return this.data.Keys;
}