/* PUBLIC VARS */ /* CONSTRUCTOR */ public ClientComm(Socket sock) { _Sock = sock; _Tp = new TextParser(); //has no constructor try { _Stream = new NetworkStream(_Sock); // precaches Plugins in constructor, if no plugin could be loaded -> Exception _Pm = new PluginManager(); _Pm.LoadPlugins(); } // PluginIns could not be loaded - quit! catch (FileNotFoundException e) { Console.WriteLine(e.Message); if (_Stream != null) { _Stream.Close(); } Console.WriteLine("Will quit now..."); Console.WriteLine("---------------------"); Console.ReadLine(); Environment.Exit(1); } catch (Exception) { throw; } // if server quits, destroy objects System.AppDomain.CurrentDomain.ProcessExit += new EventHandler(ServerQuittingHandler); Console.CancelKeyPress += new ConsoleCancelEventHandler(ServerQuittingHandler); }
public void SetUp() { this._Tp = new TextParser(); this._Pm = new PluginManager(); // set PluginPath differently (for Directory is not the same!) this._Pm.PlugPath = "C:\\Users\\broadcastzero\\0 FH\\3. Semester\\SWE\\bz_hal\\Server\\bin\\Debug\\Plugins"; this._Pm.LoadPlugins(); }
public void ReadPluginFolderTest() { _Pm = new PluginManager(); _Pm.PlugPath = _PluginPath; try { _Pm.LoadPlugins(); } catch (FileNotFoundException e) { Console.WriteLine(e.Message); } Assert.That(Directory.Exists(_PluginPath)); }
public void NoPluginFoundExceptionTest() { string[] files; List<string> dlls = new List<string>(); files = Directory.GetFiles(_PluginPath); // if file is a dll, copy it to dlls-string foreach (string s in files) { if(s.EndsWith(".dll")) { dlls.Add(s); } } if (dlls.Count == 0) { // should throw exception if no Plugin has been loaded in static list before _Pm = new PluginManager(); _Pm.LoadPlugins(); } // throw exception anyway, so that Nunit-Test is happy else { throw new FileNotFoundException(); } }
private void ServerQuittingHandler(object sender, ConsoleCancelEventArgs args) { if (ClientComm.cleaned == false) { ClientComm.cleaned = true; this._Pm = null; this._Tp = null; Console.WriteLine("---------------------"); Console.WriteLine("Garbage Collector"); Console.WriteLine("---------------------"); GC.Collect(); //force GarbageCollector to do his work Console.WriteLine("finished!"); Console.WriteLine("---------------------"); } Console.ReadLine(); }