private bool CanEmulate(PluginEnvironment environment) { try { NetworkEmulator.NetworkEmulationDriver nDriver = new NetworkEmulator.NetworkEmulationDriver(); return(nDriver.Initialize()); } catch (NetworkEmulator.NetworkEmulationAccessDeniedException eAccess) { ExecutionServices.SystemTrace.LogDebug("You do not have privileges to run network emulation" + eAccess.Message); return(false); } catch (NetworkEmulator.NetworkEmulationConnectionException eConnection) { ExecutionServices.SystemTrace.LogDebug("There was an error in your emulation profile, please check the file and try again! " + eConnection.Message); return(false); } catch (NetworkEmulator.NetworkEmulationDriverNotInstalledException eInstalled) { ExecutionServices.SystemTrace.LogDebug(eInstalled.Message); return(InstallNetworkEmulationDriver(environment)); } catch (NetworkEmulator.NetworkEmulationNotInitializedException eNonInitialized) { ExecutionServices.SystemTrace.LogDebug("Emulator not Initialized " + eNonInitialized.Message); return(false); } catch (Exception genericException) { ExecutionServices.SystemTrace.LogDebug(genericException.Message); return(InstallNetworkEmulationDriver(environment)); } }
private bool InstallNetworkEmulationDriver(PluginEnvironment environment) { bool result = false; var action = new Action(() => { ExecutionServices.SystemTrace.LogDebug("Installing Network Emulation Driver"); if (InstallNetworkEmulation(environment)) { NetworkEmulator.NetworkEmulationDriver nDriver = new NetworkEmulator.NetworkEmulationDriver(); result = nDriver.Initialize(); } else { ExecutionServices.SystemTrace.LogDebug("Unable to run network emulation on this machine"); } }); ExecutionServices.CriticalSection.Run(new Framework.Synchronization.LocalLockToken("NESTInstall", new TimeSpan(0, 5, 0), new TimeSpan(0, 5, 0)), action); return(result); }