string DetermineTransportPackage()
        {
            var transportAppSetting = AppConfig.Read(SettingsList.TransportType, "NServiceBus.MsmqTransport").Split(",".ToCharArray())[0].Trim();
            var transport           = Transports.All.FirstOrDefault(p => transportAppSetting.StartsWith(p.MatchOn, StringComparison.OrdinalIgnoreCase));

            if (transport != null)
            {
                return(transport.Name);
            }
            return(Transports.All.First(p => p.Default).Name);
        }
 public void Reload()
 {
     Service.Refresh();
     HostName         = AppConfig.Read(SettingsList.HostName, "localhost");
     Port             = AppConfig.Read(SettingsList.Port, 1234);
     LogPath          = AppConfig.Read(SettingsList.LogPath, DefaultLogPath());
     ErrorQueue       = AppConfig.Read(SettingsList.ErrorQueue, "error");
     TransportPackage = DetermineTransportPackage();
     ConnectionString = ReadConnectionString();
     Description      = GetDescription();
     ServiceAccount   = Service.Account;
 }
        public void RestoreAppConfig(string sourcePath)
        {
            if (sourcePath == null)
            {
                return;
            }
            File.Copy(sourcePath, $"{Service.ExePath}.config", true);

            // Populate the config with common settings even if they are defaults
            // Will not clobber other settings in the config
            AppConfig = new AppConfig(this);
            AppConfig.Validate();
            AppConfig.Save();
        }
 public MonitoringInstance(WindowsServiceController service)
 {
     Service   = service;
     AppConfig = new AppConfig(this);
     Reload();
 }