-
Notifications
You must be signed in to change notification settings - Fork 16
/
EDFFile.cs
43 lines (33 loc) · 1.06 KB
/
EDFFile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Collections.Generic;
namespace EOLib.Localization
{
public class EDFFile : IEDFFile
{
private readonly Dictionary<int, string> _data;
public IReadOnlyDictionary<int, string> Data => _data;
public DataFiles WhichFile { get; private set; }
public EDFFile(DataFiles whichFile)
: this(whichFile, new Dictionary<int, string>()) { }
public EDFFile(DataFiles whichFile, Dictionary<int, string> data)
{
WhichFile = whichFile;
_data = data;
}
public IEDFFile WithDataEntry(int key, string data)
{
var copy = MakeCopy(this);
copy._data[key] = data;
return copy;
}
private EDFFile MakeCopy(EDFFile input)
{
return new EDFFile(WhichFile, new Dictionary<int, string>(input._data));
}
}
public interface IEDFFile
{
IReadOnlyDictionary<int, string> Data { get; }
DataFiles WhichFile { get; }
IEDFFile WithDataEntry(int key, string data);
}
}