public override void InitMod(Mod Mod) { if (Bootables.ContainsKey(Mod.ModID)) { Sys.Ref.ConsoleSys.Error("Tried to init twice " + Mod.ModID); return; } ModSys ModSys = Sys.Ref.Shared.GetObject <ModSys>(); AssemblySys AssemblySys = Sys.Ref.Shared.GetNode <AssemblySys>(); string BootTarget = ModSys.GetManifest(Mod).Boot; if (BootTarget == null) { Sys.Ref.ConsoleSys.Error("Tried to init " + Mod.ModID + " without Boot target"); return; } Type BootType = AssemblySys.GetType(BootTarget); if (BootType == null) { Sys.Ref.ConsoleSys.Error("Tried to init " + Mod.ModID + " with invalid Boot target"); return; } IBoot NewBoot = (IBoot)Activator.CreateInstance(BootType); Bootables[Mod.ModID] = NewBoot; Bootables[Mod.ModID].AddShared(); }
public void Add(string ModID, IBoot Bootable) { if (!Bootables.ContainsKey(ModID)) { Bootables[ModID] = Bootable; } else { Sys.Ref.ConsoleSys.Error("Tried to add already registered bootable " + ModID); } }
public void Start(string inAssemblyFile) { if (string.IsNullOrEmpty(inAssemblyFile)) { throw new ArgumentNullException("inAssemblyFile"); } var assembly = Assembly.LoadFile(inAssemblyFile); var bootType = assembly.GetTypes().First(i => i.GetInterface(typeof(IBoot).FullName) == typeof(IBoot)); this._bootInstance = (IBoot)Activator.CreateInstance(bootType); this._bootInstance.Start(); }