private bool TryGetConfigurator(BooleanGenericTuple <ImageModPathTuple> selectedMod, out IConfigurator configurator, out PluginLoader loader) { var config = selectedMod.Generic.ModConfig; string dllPath = config.GetManagedDllPath(selectedMod.Generic.ModConfigPath); configurator = null; loader = null; if (!File.Exists(dllPath)) { return(false); } loader = PluginLoader.CreateFromAssemblyFile(dllPath, true, _sharedTypes, config => config.DefaultContext = AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly())); var assembly = loader.LoadDefaultAssembly(); var types = assembly.GetTypes(); var entryPoint = types.FirstOrDefault(t => typeof(IConfigurator).IsAssignableFrom(t) && !t.IsAbstract); if (entryPoint != null) { configurator = (IConfigurator)Activator.CreateInstance(entryPoint); configurator.SetModDirectory(Path.GetFullPath(Path.GetDirectoryName(selectedMod.Generic.ModConfigPath))); return(true); } return(false); }
private BooleanGenericTuple <ImageModPathTuple> MakeSaveSubscribedGenericTuple(bool isEnabled, ImageModPathTuple item) { // Make BooleanGenericTuple that saves application on Enabled change. var tuple = new BooleanGenericTuple <ImageModPathTuple>(isEnabled, item); tuple.PropertyChanged += SaveOnEnabledPropertyChanged; return(tuple); }
/// <summary> /// Filters an individual item. /// Returns true if the item should pass by the filter, else false. /// </summary> public bool FilterApp(BooleanGenericTuple <IApplicationConfig> item) { if (ModsFilter.Length <= 0) { return(true); } return(item.Generic.AppName.IndexOf(ModsFilter, StringComparison.InvariantCultureIgnoreCase) >= 0); }