Exemple #1
0
 public DictionaryWrappingIniFileSection(
     IINIFile iniFile,
     string section)
 {
     _iniFile = iniFile;
     _section = section;
 }
Exemple #2
0
 private void LoadFrom(IINIFile iniFile)
 {
     LoadSettingsFrom(iniFile);
     LoadSourcesFrom(iniFile);
     LoadBlacklistFrom(iniFile);
     LoadWhitelistFrom(iniFile);
 }
Exemple #3
0
 internal MergedIniFile(
     IINIFile iniFile,
     MergeStrategies mergeStrategy)
 {
     IniFile       = iniFile;
     MergeStrategy = mergeStrategy;
 }
Exemple #4
0
 public static IEnumerable <string> EnumerateLayouts(this IINIFile config)
 {
     return(config.Sections
            .Where(s => s.StartsWith(Constants.Sections.APP_LAYOUT_PREFIX))
            .Select(GetLayoutName)
            .Where(s => !s.IsNullOrEmpty())
            .Distinct());
 }
Exemple #5
0
 public Settings(IINIFile iniFile)
 {
     if (iniFile == null)
     {
         throw new ArgumentNullException(nameof(iniFile));
     }
     LoadFrom(iniFile);
 }
Exemple #6
0
 public DeviceReenumerator(
     ILogger logger,
     IINIFile config,
     IConfigLocator configLocator)
 {
     _logger        = logger;
     _config        = config;
     _configLocator = configLocator;
 }
Exemple #7
0
        private void LoadRawLinesInto(List <string> target, IINIFile iniFile, string section)
        {
            if (!iniFile.HasSection(section))
            {
                return;
            }
            var lines = iniFile[section].Keys.Select(k => GetFullLine(k, iniFile[section]));

            target.AddRange(lines);
        }
Exemple #8
0
 public LastLayoutUtility(
     IINIFile config,
     ILayoutRestorer layoutRestorer,
     IEventAggregator eventAggregator,
     ITrayIcon trayIcon
     )
 {
     _config         = config;
     _layoutRestorer = layoutRestorer;
     _trayIcon       = trayIcon;
     eventAggregator
     .GetEvent <LayoutRestoredEvent>()
     .Subscribe(OnLayoutRestored);
 }
Exemple #9
0
        public static T GetSetting <T>(
            this IINIFile iniFile,
            string section,
            string setting,
            T defaultValue = default(T))
        {
            if (!iniFile.HasSetting(section, setting))
            {
                return(defaultValue);
            }
            var stringValue = iniFile[section][setting];

            return(AttemptToConvert <T>(stringValue, defaultValue));
        }
Exemple #10
0
 public LayoutSaver(
     IINIFile config,
     IUserInput userInput,
     ISectionNameHelper sectionNameHelper,
     IDesktopWindowUtil desktopWindowUtil,
     IEventAggregator eventAggregator,
     ICheckListDialogFactory dialogFactory
     )
 {
     _config            = config;
     _userInput         = userInput;
     _sectionNameHelper = sectionNameHelper;
     _desktopWindowUtil = desktopWindowUtil;
     _eventAggregator   = eventAggregator;
     _dialogFactory     = dialogFactory;
 }
Exemple #11
0
        private void LoadSettingsFrom(IINIFile iniFile)
        {
            Func <string, string, string> getSetting = (key, defaultValue) =>
                                                       iniFile.GetValue(Constants.Sections.SETTINGS, key, defaultValue);

            RefreshIntervalInMinutes = getSetting(
                Constants.Keys.REFRESH_INTERVAL_IN_MINUTES,
                Constants.Defaults.ONE_DAY.ToString()
                ).AsInteger();
            HostsFile = Environment.ExpandEnvironmentVariables(getSetting(
                                                                   Constants.Keys.HOSTS_FILE,
                                                                   Constants.Defaults.WINDOWS_HOSTS_FILE_LOCATION
                                                                   ));
            CacheFolder = getSetting(Constants.Keys.CACHE_FOLDER, DetermineDefaultCacheFolder());
            var redirectIp = getSetting(Constants.Keys.REDIRECT_IP, Constants.Defaults.LOCALHOST);

            RedirectIp = IsValidIp(redirectIp) ? redirectIp : Constants.Defaults.LOCALHOST;
        }
Exemple #12
0
 public LayoutRestorer(
     IINIFile config,
     IApplicationRestarter applicationRestarter,
     ISectionNameHelper sectionNameHelper,
     IDesktopWindowUtil desktopWindowUtil,
     IEventAggregator eventAggregator,
     ITrayIcon trayIcon,
     IDeviceReenumerator deviceReenumerator
     )
 {
     _config = config;
     _applicationRestarter = applicationRestarter;
     _sectionNameHelper    = sectionNameHelper;
     _desktopWindowUtil    = desktopWindowUtil;
     _eventAggregator      = eventAggregator;
     _trayIcon             = trayIcon;
     _deviceReenumerator   = deviceReenumerator;
 }
Exemple #13
0
        private void LoadConfig(string name)
        {
            // config files will live in the user profile folder (eg C:\users\myprofile)
            var fullPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
                name);

            // if the file exists, it will be loaded; if not, then the INIFile instance
            //    will still know that when it's time to save, it should save back to that file
            _loadedConfig = new INIFile(fullPath);
            // load up the label, if we can
            ColorDisplay.Text = _loadedConfig.HasSetting("colors", "FavoriteColor")
                ? _loadedConfig["colors"]["FavoriteColor"]
                : "(no favorite color chosen yet for #1)";
            ColorDisplay.ForeColor = TryDetermineColorFor(ColorDisplay.Text);
            // reset the selected color in the drop-down
            ColorList.SelectedIndex = -1;
            // signal to the user that a color may be selected by enabling the controls
            ColorList.Enabled   = true;
            ChangeLabel.Enabled = true;
        }
Exemple #14
0
        private bool GeneratedFirstTimeConfig()
        {
            if (File.Exists(MyConfig))
            {
                return(false);
            }

            var config = new INIFile();

            config.AddSection(Sections.GENERAL);
            var general = config.GetSection(Sections.GENERAL);

            general[Settings.POLL]    = "1";
            general[Settings.BACKOFF] = "1,1,1,5,10";
            general[Settings.RESET]   = "30";

            config.AddSection(Sections.SERVICES);
            config.Persist(MyConfig);
            _config           = config;
            _configLastLoaded = Now;
            return(true);
        }
Exemple #15
0
 private void LoadConfig()
 {
     _config           = new INIFile(MyConfig);
     _configLastLoaded = Now;
 }
Exemple #16
0
 private void LoadWhitelistFrom(IINIFile iniFile)
 {
     LoadRawLinesInto(_whitelist, iniFile, Constants.Sections.WHITELIST);
 }
 private void CreateEmptySection(
     IINIFile iniFile,
     string sectionName)
 {
     iniFile.AddSection(sectionName);
 }
 public ApplicationRestarter(IINIFile config)
 {
     _config = config;
 }
Exemple #19
0
 public SectionNameHelper(IINIFile config)
 {
     _config = config;
 }
Exemple #20
0
 private void LoadBlacklistFrom(IINIFile iniFile)
 {
     LoadRawLinesInto(_blacklist, iniFile, Constants.Sections.BLACKLIST);
 }
Exemple #21
0
 private void LoadSourcesFrom(IINIFile iniFile)
 {
     LoadRawLinesInto(_sources, iniFile, Constants.Sections.SOURCES);
 }
Exemple #22
0
 private ISettings Create(IINIFile iniFile)
 {
     return(new Implementations.Settings.Settings(iniFile));
 }