示例#1
0
        public void CachedFields()
        {
            var type = typeof(Customer);
            var reflectionCache = new ReflectionCache();
            var fields = reflectionCache.GetFields(type).ToList();

            var field = type.GetField("LastName", ReflectionCache.BindingFlags);
            Assert.Contains(field, fields);

            var privateField = type.GetField("_zip", ReflectionCache.BindingFlags);
            Assert.Contains(privateField, fields);

            reflectionCache.Clear();
        }
示例#2
0
        public void CachedProperties()
        {
            var type = typeof (Customer);
            var reflectionCache = new ReflectionCache();
            var properties = reflectionCache.GetProperties(type).ToList();
            
            var property = type.GetProperty("FirstName", ReflectionCache.BindingFlags);
            Assert.Contains(property, properties);

            var protectedProperty = type.GetProperty("PhoneNumber", ReflectionCache.BindingFlags);
            Assert.Contains(protectedProperty, properties);

            reflectionCache.Clear();
        }