aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/WidgetManager.cs
diff options
context:
space:
mode:
authorMichael VanOverbeek <[email protected]>2017-06-11 11:57:31 +0000
committerGitHub <[email protected]>2017-06-11 11:57:31 +0000
commit997a81457ebb6d6523c36ca552cee143e0d92244 (patch)
treeda98985ced112b6d238811f3ca770014d67e34fc /ShiftOS.WinForms/WidgetManager.cs
parent0d75f701778a0900a58343c4c80c124279bc231f (diff)
parent107a98686a105468b5f200ebcbd27343c1210ce4 (diff)
downloadshiftos_thereturn-997a81457ebb6d6523c36ca552cee143e0d92244.tar.gz
shiftos_thereturn-997a81457ebb6d6523c36ca552cee143e0d92244.tar.bz2
shiftos_thereturn-997a81457ebb6d6523c36ca552cee143e0d92244.zip
Merge pull request #129 from RogueAI42/master
ReflectMan Saves The Day..............
Diffstat (limited to 'ShiftOS.WinForms/WidgetManager.cs')
-rw-r--r--ShiftOS.WinForms/WidgetManager.cs36
1 files changed, 6 insertions, 30 deletions
diff --git a/ShiftOS.WinForms/WidgetManager.cs b/ShiftOS.WinForms/WidgetManager.cs
index fec09f9..81a97af 100644
--- a/ShiftOS.WinForms/WidgetManager.cs
+++ b/ShiftOS.WinForms/WidgetManager.cs
@@ -16,36 +16,12 @@ namespace ShiftOS.WinForms
{
public static Dictionary<DesktopWidgetAttribute, Type> GetAllWidgetTypes()
{
- Dictionary<DesktopWidgetAttribute, Type> types = new Dictionary<WinForms.DesktopWidgetAttribute, Type>();
- foreach(var exe in System.IO.Directory.GetFiles(Environment.CurrentDirectory))
- {
- if(exe.EndsWith(".exe") || exe.EndsWith(".dll"))
- {
- try
- {
- var asm = Assembly.LoadFile(exe);
- foreach(var type in asm.GetTypes())
- {
- if (type.GetInterfaces().Contains(typeof(IDesktopWidget)))
- {
- if (Shiftorium.UpgradeAttributesUnlocked(type))
- {
- foreach (var attrib in type.GetCustomAttributes(false))
- {
- if (attrib is DesktopWidgetAttribute)
- {
- var dw = attrib as DesktopWidgetAttribute;
- types.Add(dw, type);
- }
- }
- }
- }
- }
- }
- catch { }
- }
- }
- return types;
+ var ret = new Dictionary<DesktopWidgetAttribute, Type>();
+ var types = Array.FindAll(ReflectMan.Types, t => t.GetInterfaces().Contains(typeof(IDesktopWidget)) && Shiftorium.UpgradeAttributesUnlocked(t));
+ foreach (var type in types)
+ foreach (var attrib in Array.FindAll(type.GetCustomAttributes(false), a => a is DesktopWidgetAttribute))
+ ret.Add(attrib as DesktopWidgetAttribute, type);
+ return ret;
}
internal static void SaveDetails(Type type, WidgetDetails location)