ZeroInstall.Store.Config.SetOption C# (CSharp) Méthode

SetOption() public méthode

Sets an option identified by a key.
is invalid. is invalid.
public SetOption ( string key, string value ) : void
key string The key of the option to set.
value string A string representation of the option.
Résultat void
        public void SetOption(string key, string value)
        {
            _metaData[key].Value = value;
        }

Usage Example

        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"));
        }
All Usage Examples Of ZeroInstall.Store.Config::SetOption