1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-23 05:08: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; using System.Collections.Generic;
namespace MLEM.Misc { namespace MLEM.Misc {
@ -6,11 +7,12 @@ namespace MLEM.Misc {
private Dictionary<string, object> data; private Dictionary<string, object> data;
public void SetData(string key, object data) { public void SetData(string key, object data) {
if (this.data == null)
this.data = new Dictionary<string, object>();
if (data == default) { if (data == default) {
this.data.Remove(key); if (this.data != null)
this.data.Remove(key);
} else { } else {
if (this.data == null)
this.data = new Dictionary<string, object>();
this.data[key] = data; this.data[key] = data;
} }
} }
@ -22,6 +24,8 @@ namespace MLEM.Misc {
} }
public IReadOnlyCollection<string> GetDataKeys() { public IReadOnlyCollection<string> GetDataKeys() {
if (this.data == null)
return Array.Empty<string>();
return this.data.Keys; return this.data.Keys;
} }