blob: 8dc203ae2e900e803e74fa15dc6d8abb8c20938d (
plain) (
blame)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
namespace ShiftOS.Engine
{
public static class AppLauncherDaemon
{
public static bool Contains(this AssemblyName[] asms, string name)
{
foreach(var asm in asms)
{
if (asm.FullName.Contains(name))
return true;
}
return false;
}
public static List<LauncherItem> Available()
{
List<LauncherItem> win = new List<LauncherItem>();
foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory))
{
if (asmExec.EndsWith(".dll") | asmExec.EndsWith(".exe"))
{
var asm = Assembly.LoadFrom(asmExec);
if (asm.GetReferencedAssemblies().Contains("ShiftOS.Engine") || asm.FullName.Contains("ShiftOS.Engine"))
{
foreach (var type in asm.GetTypes())
{
if (type.GetInterfaces().Contains(typeof(IShiftOSWindow)))
{
foreach (var attr in type.GetCustomAttributes(false))
{
if (attr is LauncherAttribute)
{
var launch = attr as LauncherAttribute;
if (launch.UpgradeInstalled)
{
win.Add(new LauncherItem { DisplayData = launch, LaunchType = type });
}
}
}
}
}
}
}
}
return win;
}
}
public class LauncherItem
{
public LauncherAttribute DisplayData { get; internal set; }
public Type LaunchType { get; internal set; }
}
}
|