예제 #1
0
 private void StaticallyCachePropertyInfosFor(object[] cacheAll, bool cacheFieldInfosToo)
 {
     lock (PropertyInfos)
     {
         // TODO: cache for all objects
         var toCacheFor = cacheAll[0];
         var type       = toCacheFor.GetType();
         if (PropertyInfos.ContainsKey(type))
         {
             return;
         }
         PropertyInfos[type] = new PropertyInfoContainer(
             _propertyInfoFetcher
             .GetPropertiesFor(toCacheFor,
                               BindingFlags.Instance | BindingFlags.Public));
         if (!cacheFieldInfosToo)
         {
             return;
         }
         FieldInfos[type] = type
                            .GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
                            .ToDictionary(
             fi => fi.Name,
             fi => fi
             );
     }
 }
예제 #2
0
        private void StaticallyCachePropertInfosFor(Type interfaceToMimick)
        {
            var bindingFlags = BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.Public;

            _mimickedPropInfos = new PropertyInfoContainer(
                interfaceToMimick.GetAllImplementedInterfaces()
                .Select(i => _propertyInfoFetcher
                        .GetProperties(i, bindingFlags))
                .SelectMany(c => c)
                .ToArray()
                );
        }