Beispiel #1
0
 public static void RegisterModule(Type moduleType)
 {
     if (DynamicModuleReflectionUtil.Fx45RegisterModuleDelegate != null)
     {
         DynamicModuleReflectionUtil.Fx45RegisterModuleDelegate(moduleType);
     }
     else
     {
         LegacyModuleRegistrar.RegisterModule(moduleType);
     }
 }
Beispiel #2
0
 private static DynamicModuleReflectionUtil GetInstance()
 {
     try
     {
         if (Fx45RegisterModuleDelegate != null)
         {
             return(null);
         }
         DynamicModuleReflectionUtil util = new DynamicModuleReflectionUtil();
         MethodInfo method = typeof(BuildManager).GetMethod("ThrowIfPreAppStartNotRunning", BindingFlags.NonPublic | BindingFlags.Static, null, Type.EmptyTypes, null);
         util.ThrowIfPreAppStartNotRunning = CommonReflectionUtil.MakeDelegate <Action>(method);
         CommonReflectionUtil.Assert(util.ThrowIfPreAppStartNotRunning != null);
         Type       type  = CommonAssemblies.SystemWeb.GetType("System.Web.Configuration.RuntimeConfig");
         MethodInfo info2 = type.GetMethod("GetAppConfig", BindingFlags.NonPublic | BindingFlags.Static, null, Type.EmptyTypes, null);
         util.GetAppConfig = CommonReflectionUtil.MakeDelegate <Func <object> >(info2);
         CommonReflectionUtil.Assert(util.GetAppConfig != null);
         Type   containingType = type;
         string methodName     = "get_HttpModules";
         bool   isStatic       = false;
         Type[] emptyTypes     = Type.EmptyTypes;
         Type   returnType     = typeof(HttpModulesSection);
         util._mi_RuntimeConfig_getHttpModules = CommonReflectionUtil.FindMethod(containingType, methodName, isStatic, emptyTypes, returnType);
         Type   type7     = typeof(ConfigurationElementCollection);
         string fieldName = "bReadOnly";
         bool   flag2     = false;
         Type   fieldType = typeof(bool);
         util._fi_ConfigurationElementCollection_bReadOnly = CommonReflectionUtil.FindField(type7, fieldName, flag2, fieldType);
         Type   type2         = CommonAssemblies.SystemWeb.GetType("System.Web.ModuleConfigurationInfo");
         Type   type9         = type2;
         bool   flag3         = false;
         Type[] argumentTypes = new Type[] { typeof(string), typeof(string), typeof(string) };
         util._ci_ModuleConfigurationInfo = CommonReflectionUtil.FindConstructor(type9, flag3, argumentTypes);
         Type type3 = typeof(List <>).MakeGenericType(new Type[] { type2 });
         util._type_ListOfModuleConfigurationInfo = type3;
         Type   type10     = type3;
         bool   flag4      = false;
         Type[] typeArray5 = Type.EmptyTypes;
         util._ci_ListOfModuleConfigurationInfo = CommonReflectionUtil.FindConstructor(type10, flag4, typeArray5);
         Type   type11 = typeof(HttpApplication);
         string str3   = "_moduleConfigInfo";
         bool   flag5  = true;
         Type   type12 = type3;
         util._fi_HttpApplication_moduleConfigInfo = CommonReflectionUtil.FindField(type11, str3, flag5, type12);
         Type   type13 = typeof(HttpApplication);
         string str4   = "_moduleCollection";
         bool   flag6  = false;
         Type   type14 = typeof(HttpModuleCollection);
         util._fi_HttpApplication_moduleCollection = CommonReflectionUtil.FindField(type13, str4, flag6, type14);
         Type   type4  = CommonAssemblies.SystemWeb.GetType("System.Web.Hosting.PipelineRuntime");
         Type   type15 = type4;
         string str5   = "s_ApplicationContext";
         bool   flag7  = true;
         Type   type16 = typeof(IntPtr);
         util._fi_PipelineRuntime_s_ApplicationContext = CommonReflectionUtil.FindField(type15, str5, flag7, type16);
         Type   type17     = typeof(HttpApplication);
         string str6       = "GetModuleCollection";
         bool   flag8      = false;
         Type[] typeArray7 = new Type[] { typeof(IntPtr) };
         Type   type18     = typeof(HttpModuleCollection);
         util._mi_HttpApplication_GetModuleCollection = CommonReflectionUtil.FindMethod(type17, str6, flag8, typeArray7, type18);
         Type   type19     = typeof(HttpApplication);
         string str7       = "BuildIntegratedModuleCollection";
         bool   flag9      = false;
         Type[] typeArray9 = new Type[] { type3 };
         Type   type20     = typeof(HttpModuleCollection);
         util._mi_HttpApplication_BuildIntegratedModuleCollection = CommonReflectionUtil.FindMethod(type19, str7, flag9, typeArray9, type20);
         Type   type21      = typeof(HttpModuleCollection);
         string str8        = "AddModule";
         bool   flag10      = false;
         Type[] typeArray11 = new Type[] { typeof(string), typeof(IHttpModule) };
         Type   type22      = typeof(void);
         util._mi_HttpModuleCollection_AddModule = CommonReflectionUtil.FindMethod(type21, str8, flag10, typeArray11, type22);
         return(util);
     }
     catch
     {
         return(null);
     }
 }