Esempio n. 1
0
        public static void Main(string[] args)
        {
            var test       = ReflectionGetter.GetFields(typeof(TestClass));
            var properties = ReflectionGetter.GetProperties(typeof(TestClass));

            var temp = new TestClass()
            {
                Test1 = "Test1String",
                Test2 = 2,
                Test3 = 2.5,
                Test4 = "Test4String"
            };

            var testList = ReflectionConvert.SerializeToDictionary <TestClass>(temp);


            /*
             * var methods = ReflectionGetter.GetMethods(typeof(TestClass));
             *
             * foreach(var val in test)
             * {
             *  Console.WriteLine(val.Name + ":" + val.Type.Name + ":" + val.ReflectedType.Name);
             * }
             *
             * foreach (var val in properties)
             * {
             *  Console.WriteLine(val.Name + ":" + val.Type.Name + ":" + val.ReflectedType.Name);
             * }*/


            Console.ReadLine();
        }
        public void TestSerializeIntoDictionary()
        {
            var memberList = ReflectionConvert.SerializeToDictionary <TestClass>(testClass);

            Assert.AreEqual("Test1String", memberList["Test1"].Value);
            Assert.AreEqual(2, memberList["Test2"].Value);
            Assert.AreEqual(2.5, memberList["Test3"].Value);
            Assert.AreEqual("Test4String", memberList["Test4"].Value);
        }