forked from mirrors/NBTExplorer
Static initializer gaurds
This commit is contained in:
parent
ef6102b0f4
commit
4949a35a84
3 changed files with 46 additions and 24 deletions
29
MainForm.cs
29
MainForm.cs
|
@ -22,18 +22,23 @@ namespace NBTExplorer
|
||||||
|
|
||||||
static MainForm ()
|
static MainForm ()
|
||||||
{
|
{
|
||||||
_tagIconIndex = new Dictionary<TagType, int>();
|
try {
|
||||||
_tagIconIndex[TagType.TAG_BYTE] = 0;
|
_tagIconIndex = new Dictionary<TagType, int>();
|
||||||
_tagIconIndex[TagType.TAG_SHORT] = 1;
|
_tagIconIndex[TagType.TAG_BYTE] = 0;
|
||||||
_tagIconIndex[TagType.TAG_INT] = 2;
|
_tagIconIndex[TagType.TAG_SHORT] = 1;
|
||||||
_tagIconIndex[TagType.TAG_LONG] = 3;
|
_tagIconIndex[TagType.TAG_INT] = 2;
|
||||||
_tagIconIndex[TagType.TAG_FLOAT] = 4;
|
_tagIconIndex[TagType.TAG_LONG] = 3;
|
||||||
_tagIconIndex[TagType.TAG_DOUBLE] = 5;
|
_tagIconIndex[TagType.TAG_FLOAT] = 4;
|
||||||
_tagIconIndex[TagType.TAG_BYTE_ARRAY] = 6;
|
_tagIconIndex[TagType.TAG_DOUBLE] = 5;
|
||||||
_tagIconIndex[TagType.TAG_STRING] = 7;
|
_tagIconIndex[TagType.TAG_BYTE_ARRAY] = 6;
|
||||||
_tagIconIndex[TagType.TAG_LIST] = 8;
|
_tagIconIndex[TagType.TAG_STRING] = 7;
|
||||||
_tagIconIndex[TagType.TAG_COMPOUND] = 9;
|
_tagIconIndex[TagType.TAG_LIST] = 8;
|
||||||
_tagIconIndex[TagType.TAG_INT_ARRAY] = 14;
|
_tagIconIndex[TagType.TAG_COMPOUND] = 9;
|
||||||
|
_tagIconIndex[TagType.TAG_INT_ARRAY] = 14;
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Program.StaticInitFailure(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainForm ()
|
public MainForm ()
|
||||||
|
|
|
@ -45,20 +45,25 @@ namespace NBTExplorer.Model
|
||||||
|
|
||||||
static FileTypeRegistry ()
|
static FileTypeRegistry ()
|
||||||
{
|
{
|
||||||
Register<NbtFileDataNode>(new FileTypeRecord() {
|
try {
|
||||||
NamePatternTest = NbtFileDataNode.SupportedNamePattern,
|
Register<NbtFileDataNode>(new FileTypeRecord() {
|
||||||
NodeCreate = NbtFileDataNode.TryCreateFrom,
|
NamePatternTest = NbtFileDataNode.SupportedNamePattern,
|
||||||
});
|
NodeCreate = NbtFileDataNode.TryCreateFrom,
|
||||||
|
});
|
||||||
|
|
||||||
Register<RegionFileDataNode>(new FileTypeRecord() {
|
Register<RegionFileDataNode>(new FileTypeRecord() {
|
||||||
NamePatternTest = RegionFileDataNode.SupportedNamePattern,
|
NamePatternTest = RegionFileDataNode.SupportedNamePattern,
|
||||||
NodeCreate = RegionFileDataNode.TryCreateFrom,
|
NodeCreate = RegionFileDataNode.TryCreateFrom,
|
||||||
});
|
});
|
||||||
|
|
||||||
Register<CubicRegionDataNode>(new FileTypeRecord() {
|
Register<CubicRegionDataNode>(new FileTypeRecord() {
|
||||||
NamePatternTest = CubicRegionDataNode.SupportedNamePattern,
|
NamePatternTest = CubicRegionDataNode.SupportedNamePattern,
|
||||||
NodeCreate = CubicRegionDataNode.TryCreateFrom,
|
NodeCreate = CubicRegionDataNode.TryCreateFrom,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Program.StaticInitFailure(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
Program.cs
12
Program.cs
|
@ -16,5 +16,17 @@ namespace NBTExplorer
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new MainForm());
|
Application.Run(new MainForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void StaticInitFailure (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Static Initialization Failure:");
|
||||||
|
while (e != null) {
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
Console.WriteLine(e.StackTrace);
|
||||||
|
e = e.InnerException;
|
||||||
|
}
|
||||||
|
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue