コード例 #1
0
        public void SaveConfiguration(ConfigurationItem configItem)
        {
            configItem.AssertNotNull(nameof(configItem));

            CreateConfigFileIfNecessary();
            string xml = QuickXmlSerializer.SerializeObject(configItem);

            File.WriteAllText(ConfigFilePath, xml);
        }
コード例 #2
0
        public void TestQuickXmlSerializerDynamic()
        {
            QuickXmlSerializerTestClass testObj = new QuickXmlSerializerTestClass {
                Value = "lol", Number = 1
            };
            string xml = QuickXmlSerializer.SerializeObject(testObj);

            Assert.IsNotNull(xml);

            IDictionary <string, object> deserializedObj = QuickXmlSerializer.GetDynamicObjectFromXml(xml);

            Assert.IsTrue(deserializedObj.ContainsKey("QuickXmlSerializerTestClass"));
        }
コード例 #3
0
        public void TestQuickXmlSerializer()
        {
            QuickXmlSerializerTestClass testObj = new QuickXmlSerializerTestClass {
                Value = "lol", Number = 1
            };
            string xml = QuickXmlSerializer.SerializeObject(testObj);

            Assert.IsNotNull(xml);

            QuickXmlSerializerTestClass deserializedObj = QuickXmlSerializer.DeserializeObject <QuickXmlSerializerTestClass>(xml);

            Assert.AreEqual(testObj, deserializedObj);
        }