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 ); } }
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() ); }