private static Type GetInterceptedCollectionType(Type controlCollectionType, InjectDependenciesCallbackHandler staticCallback) { AssertUtils.State(typeof(ControlCollection).IsAssignableFrom(controlCollectionType), "controlCollectionType must be of type ControlCollection"); Type interceptedCollectionType = (Type)s_interceptedCollectionTypeCache[controlCollectionType]; if (interceptedCollectionType == null) { lock (s_interceptedCollectionTypeCache) { MethodInfo callbackMethod = staticCallback.Method; AssertUtils.State(callbackMethod.IsStatic && callbackMethod.IsPublic, "staticCallback must be a public static method"); interceptedCollectionType = (Type)s_interceptedCollectionTypeCache[controlCollectionType]; if (interceptedCollectionType == null) { SupportsWebDependencyInjectionTypeBuilder builder = new SupportsWebDependencyInjectionTypeBuilder(controlCollectionType, s_collectionMethods, callbackMethod); interceptedCollectionType = builder.BuildProxyType(); s_interceptedCollectionTypeCache[controlCollectionType] = interceptedCollectionType; } } } return(interceptedCollectionType); }
private static Type GetInterceptedCollectionType(Type controlCollectionType, InjectDependenciesCallbackHandler staticCallback) { AssertUtils.State( typeof(ControlCollection).IsAssignableFrom(controlCollectionType), "controlCollectionType must be of type ControlCollection" ); Type interceptedCollectionType = (Type)s_interceptedCollectionTypeCache[controlCollectionType]; if (interceptedCollectionType == null) { lock (s_interceptedCollectionTypeCache) { MethodInfo callbackMethod = staticCallback.Method; AssertUtils.State(callbackMethod.IsStatic && callbackMethod.IsPublic, "staticCallback must be a public static method"); interceptedCollectionType = (Type)s_interceptedCollectionTypeCache[controlCollectionType]; if (interceptedCollectionType == null) { SupportsWebDependencyInjectionTypeBuilder builder = new SupportsWebDependencyInjectionTypeBuilder(controlCollectionType, s_collectionMethods, callbackMethod); interceptedCollectionType = builder.BuildProxyType(); s_interceptedCollectionTypeCache[controlCollectionType] = interceptedCollectionType; } } } return interceptedCollectionType; }