public void Test()
        {
            var strs = new string[] { "Test1", "Test2" };

            this.StrValue     = "TestValue";
            this.IntValue     = 5;
            this.DoubleValue  = 10.4;
            this.StringValues = strs;

            XElement a = new XElement("Root");

            RcpaOptionUtils.SaveToXml(this, a);
            //Console.WriteLine(a.ToString());

            this.StrValue     = "";
            this.IntValue     = 10;
            this.DoubleValue  = 5.5;
            this.StringValues = null;

            RcpaOptionUtils.LoadFromXml(this, a);
            Assert.AreEqual("TestValue", this.StrValue);
            Assert.AreEqual(5, this.IntValue);
            Assert.AreEqual(10.4, this.DoubleValue);
            Assert.IsNotNull(this.StringValues);
            Assert.AreEqual(strs.Length, this.StringValues.Length);
            for (int i = 0; i < strs.Length; i++)
            {
                Assert.AreEqual(strs[i], this.StringValues[i]);
            }
        }
Exemplo n.º 2
0
        public virtual void LoadOption()
        {
            try
            {
                XElement option = GetOption();

                RegisterRcpaComponent();

                this.componentList.LoadFromXml(option);

                RcpaOptionUtils.LoadFromXml(this, option);

                this.componentList.ResetEnabledByPrecondition();
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Load option error : " + ex.Message);
            }
            OnAfterLoadOption(new EventArgs());
        }
Exemplo n.º 3
0
        public virtual void SaveOption()
        {
            try
            {
                XElement option = GetOption();

                XElement appSetting = option.Element("appSettings");
                if (appSetting != null)
                {
                    appSetting.Remove();
                }

                this.componentList.RemoveFromXml(option);
                this.componentList.SaveToXml(option);

                RcpaOptionUtils.SaveToXml(this, option);

                option.Save(ConfigFileName);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Save option error : " + ex.Message);
            }
        }