public static void SetNotifyOptionsRegistry(string appKeyIn, string serverIn, string portIn, string fromAddressIn, string[] toAddressesIn)
        {
            SimpleConfig appConfig = new SimpleConfig();

            appConfig.Set("NotifyMailAddresses", string.Join(",", toAddressesIn));
            appConfig.Set("NotifyMailServer", serverIn);
            appConfig.Set("NotifyMailFromAddress", fromAddressIn);
            try {
                appConfig.Set("NotifyMailPort", int.Parse(portIn).ToString());
            } catch (FormatException ex) {
                throw new SimpleNotifyMailerException(ex.Message);
            }

            appConfig.SaveConfigRegistry(appKeyIn);
        }
Beispiel #2
0
        public void TestSimpleConfigUserSaveLoadRegistry()
        {
            string appKey       = "SimpleConfigTests";
            string testKey1     = "Test";
            string testVal1     = "Bears";
            string testKey2     = "TestArray";
            string testVal2     = "Bears,Birds,Barns";
            string testVal2Sub2 = "Barns";

            SimpleConfig config = new SimpleConfig();

            config.Set(testKey1, testVal1);
            config.Set(testKey2, testVal2);
            config.SaveConfigRegistry(appKey, SimpleConfigRegistryNode.NODE_DEFAULT, SimpleConfigRegistryHive.HIVE_LOCAL_USER);
            Assert.AreEqual(config.Get(testKey1, ""), testVal1);
            Assert.AreEqual(config.GetList(testKey2, ',')[2], testVal2Sub2);

            SimpleConfig testConfig = SimpleConfig.LoadConfigRegistry(appKey, SimpleConfigRegistryNode.NODE_DEFAULT, SimpleConfigRegistryHive.HIVE_LOCAL_USER);

            Assert.AreEqual(testConfig.Get(testKey1, ""), testVal1);
            Assert.AreEqual(testConfig.GetList(testKey2, ',')[2], testVal2Sub2);
        }