Ejemplo 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 TestGetProperties()
        {
            var fieldList = ReflectionGetter.GetProperties(typeof(TestClass));

            Assert.IsTrue(fieldList.Contains(new Property()
            {
                Name = "Test1", Type = typeof(string), ReflectedType = typeof(TestClass), Value = "-1"
            }));
            Assert.IsTrue(fieldList.Contains(new Property()
            {
                Name = "Test2", Type = typeof(int), ReflectedType = typeof(TestClass), Value = -1
            }));
        }