public static Config Load([NotNull] string path) { Log.Debug("Loading Config from: " + path); var config = new Config(); config.ReadFromIniFile(path); return config; }
/// <inheritdoc/> public void ShowConfig(Config config, ConfigTab configTab) { #region Sanity checks if (config == null) throw new ArgumentNullException(nameof(config)); #endregion Console.Write(config.ToString()); }
/// <summary> /// Creates a new sequential download fetcher. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="store">The location to store the downloaded and unpacked <see cref="Store.Model.Implementation"/>s in.</param> /// <param name="handler">A callback object used when the the user needs to be informed about progress.</param> public SequentialFetcher([NotNull] Config config, [NotNull] IStore store, [NotNull] ITaskHandler handler) : base(store, handler) { #region Sanity checks if (config == null) throw new ArgumentNullException("config"); #endregion _config = config; }
public static Config Load() { var config = new Config(); config.ReadFromAppSettings(); config.ReadFromIniFiles(); if (WindowsUtils.IsWindowsNT) config.ReadFromRegistry(); return config; }
/// <summary> /// Creates a new Python solver. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="feedCache">The underlying cache backing the <paramref name="feedManager"/>.</param> /// <param name="feedManager">Provides access to remote and local <see cref="Feed"/>s. Handles downloading, signature verification and caching.</param> /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param> public PythonSolver([NotNull] Config config, [NotNull] IFeedManager feedManager, [NotNull] IFeedCache feedCache, [NotNull] ITaskHandler handler) { #region Sanity checks if (config == null) throw new ArgumentNullException("config"); if (feedManager == null) throw new ArgumentNullException("feedManager"); if (feedCache == null) throw new ArgumentNullException("feedCache"); if (handler == null) throw new ArgumentNullException("handler"); #endregion _config = config; _feedManager = feedManager; _feedCache = feedCache; _handler = handler; }
/// <summary> /// Creates a new simple solver. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="store">Used to check which <see cref="Implementation"/>s are already cached.</param> /// <param name="feedManager">Provides access to remote and local <see cref="Feed"/>s. Handles downloading, signature verification and caching.</param> /// <param name="packageManager">An external package manager that can install <see cref="PackageImplementation"/>s.</param> /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param> public BacktrackingSolver([NotNull] Config config, [NotNull] IFeedManager feedManager, [NotNull] IStore store, [NotNull] IPackageManager packageManager, [NotNull] ITaskHandler handler) { #region Sanity checks if (config == null) throw new ArgumentNullException(nameof(config)); if (feedManager == null) throw new ArgumentNullException(nameof(feedManager)); if (store == null) throw new ArgumentNullException(nameof(store)); if (packageManager == null) throw new ArgumentNullException(nameof(packageManager)); if (handler == null) throw new ArgumentNullException(nameof(handler)); #endregion _config = config; _store = store; _packageManager = packageManager; _feedManager = feedManager; _handler = handler; }
/// <summary> /// Creates a new trust manager. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="openPgp">The OpenPGP-compatible system used to validate the signatures.</param> /// <param name="trustDB">A database of OpenPGP signature fingerprints the users trusts to sign <see cref="Feed"/>s coming from specific domains.</param> /// <param name="feedCache">Provides access to a cache of <see cref="Feed"/>s that were downloaded via HTTP(S).</param> /// <param name="handler">A callback object used when the the user needs to be asked questions.</param> public TrustManager([NotNull] Config config, [NotNull] IOpenPgp openPgp, [NotNull] TrustDB trustDB, [NotNull] IFeedCache feedCache, [NotNull] ITaskHandler handler) { #region Sanity checks if (config == null) throw new ArgumentNullException("config"); if (openPgp == null) throw new ArgumentNullException("openPgp"); if (trustDB == null) throw new ArgumentNullException("trustDB"); if (feedCache == null) throw new ArgumentNullException("feedCache"); if (handler == null) throw new ArgumentNullException("handler"); #endregion _config = config; _openPgp = openPgp; _trustDB = trustDB; _feedCache = feedCache; _handler = handler; }
public void TestGetSetValue() { var config = new Config(); config.Invoking(x => x.SetOption("Test", "Test")).ShouldThrow<KeyNotFoundException>(); config.HelpWithTesting.Should().BeFalse(); config.GetOption("help_with_testing").Should().Be("False"); config.SetOption("help_with_testing", "True"); config.Invoking(x => x.SetOption("help_with_testing", "Test")).ShouldThrow<FormatException>(); config.HelpWithTesting.Should().BeTrue(); config.GetOption("help_with_testing").Should().Be("True"); config.SetOption("freshness", "10"); config.Freshness.Should().Be(TimeSpan.FromSeconds(10)); config.GetOption("freshness").Should().Be("10"); }
/// <summary> /// Creates a new <see cref="SelectionCandidate"/> provider. /// </summary> /// <param name="config">User settings controlling network behaviour, solving, etc.</param> /// <param name="feedManager">Provides access to remote and local <see cref="Feed"/>s. Handles downloading, signature verification and caching.</param> /// <param name="store">Used to check which <see cref="Implementation"/>s are already cached.</param> /// <param name="packageManager">An external package manager that can install <see cref="PackageImplementation"/>s.</param> /// <param name="languages">The preferred languages for the implementation.</param> public SelectionCandidateProvider([NotNull] Config config, [NotNull] IFeedManager feedManager, [NotNull] IStore store, [NotNull] IPackageManager packageManager, [NotNull] LanguageSet languages) { #region Sanity checks if (config == null) throw new ArgumentNullException(nameof(config)); if (feedManager == null) throw new ArgumentNullException(nameof(feedManager)); if (store == null) throw new ArgumentNullException(nameof(store)); if (packageManager == null) throw new ArgumentNullException(nameof(packageManager)); if (languages == null) throw new ArgumentNullException(nameof(languages)); #endregion _config = config; _feedManager = feedManager; _isCached = BuildCacheChecker(store); _packageManager = packageManager; _comparer = new TransparentCache<FeedUri, SelectionCandidateComparer>(id => new SelectionCandidateComparer(config, _isCached, _interfacePreferences[id].StabilityPolicy, languages)); }
public ConfigDialog(Config config) { InitializeComponent(); if (Locations.IsPortable) Text += @" - " + Resources.PortableMode; HandleCreated += delegate { Program.ConfigureTaskbar(this, Text, subCommand: ".Config", arguments: Configure.Name); }; _config = config; ConfigToControls(); LoadImplementationDirs(); LoadCatalogSources(); LoadTrust(); panelTrustedKeys.Controls.Add(treeViewTrustedKeys); treeViewTrustedKeys.CheckedEntriesChanged += treeViewTrustedKeys_CheckedEntriesChanged; if (WindowsUtils.IsWindows) LoadLanguages(); else tabLanguage.Visible = false; }
public static Config Load() { // Locate all applicable config files var paths = Locations.GetLoadConfigPaths("0install.net", true, "injector", "global"); // Accumulate values from all files var config = new Config(); foreach (var path in paths.Reverse()) // Read least important first config.ReadFromIniFile(path); // Apply Windows registry policies (override existing config) if (WindowsUtils.IsWindowsNT) { using (var registryKey = Registry.LocalMachine.OpenSubKey(RegistryPolicyPath, writable: false)) if (registryKey != null) config.ReadFromRegistry(registryKey); using (var registryKey = Registry.CurrentUser.OpenSubKey(RegistryPolicyPath, writable: false)) if (registryKey != null) config.ReadFromRegistry(registryKey); } return config; }
/// <inheritdoc/> public void ShowConfig(Config config, ConfigTab configTab) { // No UI, so nothing to do }
/// <inheritdoc/> public bool Equals(Config other) { if (other == null) return false; return _metaData.All(property => property.Value.Value == other.GetOption(property.Key)); }
/// <summary> /// Creates a deep copy of this <see cref="Config"/> instance. /// </summary> /// <returns>The new copy of the <see cref="Config"/>.</returns> public Config Clone() { var newConfig = new Config(); foreach (var property in _metaData) newConfig.SetOption(property.Key, GetOption(property.Key)); return newConfig; }
public void TestGetSetValue() { var config = new Config(); Assert.Throws<KeyNotFoundException>(() => config.SetOption("Test", "Test")); Assert.IsFalse(config.HelpWithTesting); Assert.AreEqual("False", config.GetOption("help_with_testing")); config.SetOption("help_with_testing", "True"); Assert.Throws<FormatException>(() => config.SetOption("help_with_testing", "Test")); Assert.IsTrue(config.HelpWithTesting); Assert.AreEqual("True", config.GetOption("help_with_testing")); config.SetOption("freshness", "10"); Assert.AreEqual(TimeSpan.FromSeconds(10), config.Freshness); Assert.AreEqual("10", config.GetOption("freshness")); }
/// <inheritdoc/> public void ShowConfig(Config config, ConfigTab configTab) { #region Sanity checks if (config == null) throw new ArgumentNullException(nameof(config)); #endregion // TODO: Implement }
private void SyncWizard_Load(object sender, EventArgs e) { try { _config = Config.Load(); } #region Error handling catch (IOException ex) { Log.Error(ex); Msg.Inform(this, ex.Message, MsgSeverity.Error); Close(); } catch (UnauthorizedAccessException ex) { Log.Error(ex); Msg.Inform(this, ex.Message, MsgSeverity.Error); Close(); } catch (InvalidDataException ex) { Log.Error(ex); Msg.Inform(this, ex.Message, MsgSeverity.Error); Close(); } #endregion }