public void InitializeHostedService(IServiceConfigurator <DirectoryMonitor> cfg)
        {
            cfg.ConstructUsing((d, name, channel) => new DirectoryMonitor(GetServicesDirectory(), channel));

            cfg.WhenStarted(dm => dm.Start());
            cfg.WhenStopped(dm => dm.Stop());
        }
        public void InitializeHostedService([NotNull] IServiceConfigurator <DirectoryMonitor> cfg)
        {
            if (cfg == null)
            {
                throw new ArgumentNullException("cfg");
            }

            cfg.ConstructUsing((d, name, channel) => new DirectoryMonitor(GetServicesDirectory(), channel));

            cfg.WhenStarted(dm => dm.Start());
            cfg.WhenStopped(dm => dm.Stop());
        }