private void Shutdown() { this.StopAllModules(); this.DisposeAllScouts(); this.Dispose(); if(homeService!=null) homeService.Stop(); this.runningScouts = null; this.runningModules = null; this.runningModulesStates = null; this.registeredPorts = null; this.registeredPorts = null; this.config = null; this.allAddinTokens = null; this.policyEngine = null; //this.gadgetListener = null; this.guiService = null; this.homeService = null; this.infoService = null; this.discoveryHelperService = null; this.heartbeatService = null; this.random = null; GC.Collect(); //finally close the logger object if (logger != null) logger.Close(); }
private void Initialize(string[] arguments) { safeToGoOnline = false; guiService = null; homeService = null; //initialize various data structures random = new Random(); runningModules = new Dictionary<VModule, ModuleInfo>(); runningScouts = new Dictionary<string, Tuple<ScoutInfo, IScout>>(); runningModulesStates = new Dictionary<VModule, VModuleState>(); registeredPorts = new Dictionary<VPort, VModule>(); //this initializes the settings to what was default (in the code) Settings.Initialize(); ArgumentsDictionary argsDict = ProcessArguments(arguments); //were we supplied a non-default configuration directory? if (!DEFAULT_COMMAND_LINE_ARG_VAL.Equals((string)argsDict["ConfigDir"])) Settings.SetParameter("ConfigDir", (string) argsDict["ConfigDir"]); //this overwrites the settings to what was in the configuration file config = new Configuration(Settings.ConfigDir); config.ParseSettings(); //now, overwrite the settings with those on the command line foreach (var parameter in argsDict.Keys) { if (parameter.Equals("Help")) continue; if (!DEFAULT_COMMAND_LINE_ARG_VAL.Equals((string)argsDict[parameter])) config.UpdateConfSetting(parameter, argsDict[parameter]); } //initialize the logger logger = InitLogger(Settings.LogFile); logger.Log("Platform initialized"); //set the logger for config and read remaining config fines config.SetLogger(logger); config.ReadConfiguration(); //initialize the policy enginer policyEngine = new PolicyEngine(logger); policyEngine.Init(config); //rebuild the addin tokens this.rebuildAddInTokens(); homeStoreInfo = new HomeStoreInfo(logger); _consoleHandler = new PlatformConsoleCtrlHandlerDelegate(ConsoleEventHandler); SetConsoleCtrlHandler(_consoleHandler, true); }