Example #1
0
        public RunAsService(XmlConfig.XmlConfig settings, HookRepository repository, CommandBuilder builder)
        {
            _repository = repository;
            _builder = builder;
            _settings = settings;

            InitProperties();
        }
Example #2
0
        private bool Init()
        {
            Log.Debug("Initialize from configuration file...");

            try
            {
                var currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                if (currentDir == null)
                    throw new IOException("Cannot retrieve the current assembly directory name.");
                _settings =
                    new XmlConfig.XmlConfig(
                        Path.Combine(currentDir,
                                     "configuration.xml"));

                InitProperties();

                _repository = new HookRepository(_settings.GetItem("exitHooks").Value, _settings, this);
                _builder = new CommandBuilder(new ProcessManager());

                return true;
            }
            catch (Exception ex)
            {
                Log.Error("Service can't be initialized", ex);
            }

            return false;
        }