コード例 #1
0
            public void ProcessRequest(HttpContext context)
            {
                var    module = _rc.RouteData.Values["module"].ToString();
                var    method = _rc.RouteData.Values["method"].ToString();
                object id;

                _rc.RouteData.Values.TryGetValue("id", out id);
                //var urlHelper = new UrlHelper(_rc);

                var type = ModulesCatalog.GetModule(new HttpApplicationStateWrapper(context.Application), module, false);

                if (type == null)
                {
                    if (ModulesCatalog._ts.TraceInfo)
                    {
                        Debug.WriteLine("{0}: Cannot create type from module {1}", ModulesCatalog._ts.DisplayName, module);
                    }

                    return;
                }

                var r = type.CreateInstance((mtype, atype) =>
                {
                    if (typeof(UrlHelper).IsAssignableFrom(mtype) && !typeof(UrlHelper).IsAssignableFrom(atype))
                    {
                        return(new UrlHelper(_rc));
                    }

                    return(null);
                }) as IModuleHandler;

                if (r == null)
                {
                    if (ModulesCatalog._ts.TraceInfo)
                    {
                        Debug.WriteLine("{0}: Module {1} does not implement IModuleHandler", ModulesCatalog._ts.DisplayName, module);
                    }

                    return;
                }

                string view;

                if (!r.Call(method, id, _rc, out view))
                {
                    return;
                }

                _rc.RouteData.Values["controller"] = "Empty";
                using (var ctrl = new EmptyController())
                {
                    var cc = new ControllerContext(_rc, ctrl);
                    ctrl.Initialize(_rc, cc);
                    var ct = new ViewContext(cc, new View(), cc.Controller.ViewData, cc.Controller.TempData, context.Response.Output);
                    var h  = new HtmlHelper(ct, new ViewDataContainer(cc.Controller.ViewData));

                    context.Response.Output.Write(h.RenderModule(r, view).ToHtmlString());
                }
            }
コード例 #2
0
ファイル: ModuleExtensions.cs プロジェクト: kouweizhong/webex
        public static string GetModuleName(this IModule module)
        {
            if (module == null)
            {
                throw new ArgumentNullException(nameof(module));
            }

            return(ModulesCatalog.GetModuleName(module.GetType()));
        }
コード例 #3
0
        public Type GetDependencyType(HttpApplicationStateBase appState = null)
        {
            if (_type != null)
            {
                return(_type);
            }

            return(ModulesCatalog.GetModule(appState, _moduleName, _ignoreCase));
        }
コード例 #4
0
 internal static CachedModule _GetModule(this ControllerBase ctrl, string moduleName, bool ignoreCase = false)
 {
     return(WebExModuleExtensions._GetModule(ctrl.ControllerContext.RequestContext.HttpContext.Items, ModulesCatalog.GetModule(ctrl.ControllerContext.HttpContext.Application, moduleName, ignoreCase)));
 }
コード例 #5
0
 public static IModule LoadModule(this ControllerBase ctrl, string moduleName, bool ignoreCase, params object[] args)
 {
     return(LoadModule(ctrl, ModulesCatalog.GetModule(ctrl.ControllerContext.HttpContext.Application, moduleName, ignoreCase), args));
 }
コード例 #6
0
 internal static CachedModule _GetModule(this HtmlHelper helper, string moduleName, bool ignoreCase = false)
 {
     return(WebExModuleExtensions._GetModule(helper.ViewContext.RequestContext.HttpContext.Items, ModulesCatalog.GetModule(helper.ViewContext.HttpContext.Application, moduleName, ignoreCase)));
 }