From 1a0d863263eed70268ae110d0f6b546a8e09325a Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 19 Feb 2017 10:11:50 -0500 Subject: [PATCH] fix bug with win.open type prober --- ShiftOS_TheReturn/Commands.cs | 60 ++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 401d1f3..f58ceff 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -615,41 +615,45 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); if (asmExec.EndsWith(".exe") || asmExec.EndsWith(".dll")) { var asm = Assembly.LoadFile(asmExec); - - foreach (var type in asm.GetTypes()) + try { - if (type.BaseType == typeof(UserControl)) + foreach (var type in asm.GetTypes()) { - foreach (var attr in type.GetCustomAttributes(false)) + if (type.BaseType == typeof(UserControl)) { - if (attr is WinOpenAttribute) + foreach (var attr in type.GetCustomAttributes(false)) { - if (app == (attr as WinOpenAttribute).ID) + if (attr is WinOpenAttribute) { - if (SaveSystem.CurrentSave.Upgrades.ContainsKey(app)) + if (app == (attr as WinOpenAttribute).ID) { - if (Shiftorium.UpgradeInstalled(app)) + if (SaveSystem.CurrentSave.Upgrades.ContainsKey(app)) + { + if (Shiftorium.UpgradeInstalled(app)) + { + IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow; + AppearanceManager.SetupWindow(frm); + return true; + } + else + { + throw new Exception($"{app} was not found on your system! Try looking in the shiftorium..."); + } + } + else { IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow; AppearanceManager.SetupWindow(frm); return true; } - else - { - throw new Exception($"{app} was not found on your system! Try looking in the shiftorium..."); - } - } - else - { - IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow; - AppearanceManager.SetupWindow(frm); - return true; } } } } } } + catch { } + } } @@ -660,24 +664,28 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); { if (asmExec.EndsWith(".exe") || asmExec.EndsWith(".dll")) { - var asm = Assembly.LoadFile(asmExec); - - foreach (var type in asm.GetTypes()) + try { - if (type.GetInterfaces().Contains(typeof(IShiftOSWindow))) + var asm = Assembly.LoadFile(asmExec); + + foreach (var type in asm.GetTypes()) { - foreach (var attr in type.GetCustomAttributes(false)) + if (type.GetInterfaces().Contains(typeof(IShiftOSWindow))) { - if (attr is WinOpenAttribute) + foreach (var attr in type.GetCustomAttributes(false)) { - if (Shiftorium.UpgradeAttributesUnlocked(type)) + if (attr is WinOpenAttribute) { - Console.WriteLine("win.open{app:\"" + (attr as WinOpenAttribute).ID + "\"}"); + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + Console.WriteLine("win.open{app:\"" + (attr as WinOpenAttribute).ID + "\"}"); + } } } } } } + catch { } } }