Ejemplo n.º 1
0
        /// <summary>
        /// Gets the serializer for the config type.
        /// </summary>
        /// <typeparam name="TConfig">The config type.</typeparam>
        /// <returns>The serializer for the config type.</returns>
        public static SilverConfigXmlSerializer <TConfig> GetSerializerFor <TConfig>() where TConfig : new()
        {
            if (!serializers.ContainsKey(typeof(TConfig)))
            {
                serializers[typeof(TConfig)] = new SilverConfigXmlSerializer <TConfig>();
            }

            return((SilverConfigXmlSerializer <TConfig>)serializers[typeof(TConfig)]);
        }
Ejemplo n.º 2
0
        public void Deserializes()
        {
            var sC = new SilverConfigXmlSerializer<TestConfig>();
            var config = sC.Deserialize(TestConfig.Output);

            Assert.AreEqual(config.Test, "Test1");
            Assert.AreEqual(config.Test2, "Test2");
            Assert.AreEqual(config.TestInt, 10);

            var i = 0;
            foreach (var value in new[] { 1, 1, 2, 3, 5, 8, 13 })
            {
                Assert.AreEqual(value, config.TestInts[i]);
                i++;
            }

            for (var n = 0; n < 3; n++)
                Assert.AreEqual(false, config.SubConfigs[n].Bool);

            Assert.AreEqual(false, config.SingleSubConfig.Bool);
        }
Ejemplo n.º 3
0
 public void Serializes()
 {
     var sC = new SilverConfigXmlSerializer<TestConfig>();
     Assert.AreEqual(TestConfig.Output, sC.Serialize(new TestConfig()));
 }