private ObjectPath CreateEngine(string name, ObjectPath engineSettings) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (engineSettings == null) { throw new ArgumentNullException("engineSettings"); } if (engines.ContainsKey(name)) { return(engines[name].Path); } Console.WriteLine("Settings: {0} - {1}", engineSettings, engineSettings); IEngineSettings settings = this.engineSettings[engineSettings]; ObjectPath path = new ObjectPath(string.Format(EnginePath, name)); EngineAdapter adapter = new EngineAdapter(name, (EngineSettingsAdapter)settings, path); engines.Add(name, adapter); TorrentService.Bus.Register(path, adapter); return(path); }
public void DestroyEngine(string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (!engines.ContainsKey(name)) { throw new ArgumentException("The engine does not exist"); } EngineAdapter engine = engines[name]; engines.Remove(name); foreach (System.Threading.WaitHandle h in engine.Engine.StopAll()) { h.WaitOne(2000, true); } engine.SaveState(); // Dispose will recursively unregister everything from the bus engine.Dispose(); }
private ObjectPath CreateEngine(string name, ObjectPath engineSettings) { if (string.IsNullOrEmpty (name)) throw new ArgumentNullException ("name"); if (engineSettings == null) throw new ArgumentNullException ("engineSettings"); if (engines.ContainsKey (name)) return engines[name].Path; Console.WriteLine ("Settings: {0} - {1}", engineSettings, engineSettings); IEngineSettings settings = this.engineSettings[engineSettings]; ObjectPath path = new ObjectPath (string.Format (EnginePath, name)); EngineAdapter adapter = new EngineAdapter (name, (EngineSettingsAdapter)settings, path); engines.Add(name, adapter); TorrentService.Bus.Register (path, adapter); return path; }