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:
parent
18c79bbf3a
commit
52328cc18d
1 changed files with 7 additions and 3 deletions
|
@ -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) {
|
||||||
|
if (this.data != null)
|
||||||
this.data.Remove(key);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue