private void LoadController(IApplication application) { Utils.LoadAssembly(a => { foreach (Type type in a.GetTypes()) { if (IKende.IKendeCore.GetTypeAttributes<ControllerAttribute>(type, false).Length > 0 && !type.IsAbstract) { "load {0} controller".Log4Info(type); object controller = Activator.CreateInstance(type); Controllers.Add(controller); foreach (System.Reflection.MethodInfo method in type.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)) { try { ParameterInfo[] pis = method.GetParameters(); if (pis.Length == 2 && (pis[0].ParameterType == typeof(ISession))) { IMethodHandler handler = new MethodHandler(controller, method, application); mHandlers[pis[1].ParameterType] = handler; "load {0}->{1} action success".Log4Info(type, method.Name); } } catch (Exception e_) { "load {0}->{1} action error".Log4Error(e_, type, method.Name); } } } } }); }
private void LoadController(IApplication application) { Utils.LoadAssembly(a => { foreach (Type type in a.GetTypes()) { if (IKende.IKendeCore.GetTypeAttributes <ControllerAttribute>(type, false).Length > 0 && !type.IsAbstract) { "load {0} controller".Log4Info(type); object controller = Activator.CreateInstance(type); Controllers.Add(controller); foreach (System.Reflection.MethodInfo method in type.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)) { try { ParameterInfo[] pis = method.GetParameters(); if (pis.Length == 2 && (pis[0].ParameterType == typeof(ISession))) { IMethodHandler handler = new MethodHandler(controller, method, application); mHandlers[pis[1].ParameterType] = handler; "load {0}->{1} action success".Log4Info(type, method.Name); } } catch (Exception e_) { "load {0}->{1} action error".Log4Error(e_, type, method.Name); } } } } }); }