public void Should_clear_plugins() { _plugins.Append(Plugin <IPluginType> .Create()); _plugins.Count().ShouldEqual(1); _plugins.Clear(); _plugins.ShouldBeEmpty(); }
/// <summary> /// The method that is called to start the backgound task. /// </summary> /// <param name="p_objArgs">Arguments to for the task execution.</param> /// <returns>Always <c>null</c>.</returns> protected override object DoWork(object[] p_objArgs) { OverallProgress = 0; OverallProgressStepSize = 1; OverallProgressMaximum = Plugins.Count(); ShowItemProgress = false; KeyValuePair <string, string> kvpMD5 = new KeyValuePair <string, string>(null, null); if (TimestampLoadOrder) { SetTimestampLoadOrder(Plugins); } else { if (WriteLoadOrderFile(FilePath, Plugins)) { using (var fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { SHA256CryptoServiceProvider sha = new SHA256CryptoServiceProvider(); byte[] hash = sha.ComputeHash(fs); string strSHA = BitConverter.ToString(hash).Replace("-", string.Empty); kvpMD5 = new KeyValuePair <string, string>(Path.GetFileName(FilePath), strSHA); } } } return(kvpMD5); }
public void LoadPluginView(int selectedIndex) { if (Plugins.Count() <= selectedIndex) { return; } Context = _loader.LoadPluginViewContext(Plugins, selectedIndex); RaisePropertyChanged(nameof(Context)); }
public Manager() { AggregateCatalog catalog = new AggregateCatalog(); catalog.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory)); catalog.Catalogs.Add(new DirectoryCatalog(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"))); CompositionContainer container = new CompositionContainer(catalog); container.ComposeParts(this); if (Plugins.Count() != 0) { Plugins.ToList().ForEach(p => Operations.Add(p.Name, (i) => p.Operate(i))); Headers = Operations.Keys.ToArray(); } }
/// <summary> /// The method that is called to start the backgound task. /// </summary> /// <param name="p_objArgs">Arguments to for the task execution.</param> /// <returns>Always <c>null</c>.</returns> protected override object DoWork(object[] p_objArgs) { OverallProgress = 0; OverallProgressStepSize = 1; OverallProgressMaximum = Plugins.Count(); ShowItemProgress = false; if (TimestampLoadOrder) { SetTimestampLoadOrder(Plugins); } else { WriteLoadOrderFile(FilePath, Plugins); } return(null); }
public PluginManager() { AggregateCatalog catalog = new AggregateCatalog(); var pa = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"); catalog.Catalogs.Add(new DirectoryCatalog(pa)); CompositionContainer container = new CompositionContainer(catalog); container.ComposeParts(this); Headers = new List <string>(); if (Plugins.Count() != 0) { Plugins.ToList() .ForEach(p => plgs.Add(p.Name, (employee) => p.Handle(employee) ) ); Headers.AddRange(plgs.Keys.ToList()); } }
private Dictionary <string, PluginStats> GetPluginStats() { var pluginTypes = Plugins.Select(p => p.PluginType).Distinct(); // these plugins is already in use or planed to be used in the future, count'em as busy. var reservedPluginUrns = JobRepository.ActiveJobs() .SelectMany(j => j.Plan.Tasks.Where(t => t.State != ExecutionState.Done).Select(t => t.PluginUrn)) .Distinct(); return(pluginTypes.ToDictionary(type => type, type => new PluginStats() { TotalCount = Plugins.Count(p => p.PluginType == type), BusyCount = Plugins.Count( p => p.PluginType == type && (p.Busy || (p.AsyncOperation && reservedPluginUrns.Contains(p.Urn)))), FreePlugin = new Stack <IPlugin>(Plugins.Where( p => p.PluginType == type && !(p.Busy || (p.AsyncOperation && reservedPluginUrns.Contains(p.Urn))))) })); }
public Manager() { AggregateCatalog catalog = new AggregateCatalog(); catalog.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory)); catalog.Catalogs.Add(new DirectoryCatalog(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"))); CompositionContainer container = new CompositionContainer(catalog); try { container.ComposeParts(this); } catch (System.Reflection.ReflectionTypeLoadException compositionException) { Console.WriteLine(compositionException.LoaderExceptions.ToString()); } if (Plugins.Count() != 0) { Plugins.ToList().ForEach(p => Plg.Add(p.PluginName, (i) => p.PluginWork(i))); Headers = Plg.Keys.ToArray(); } }