Ejemplo n.º 1
0
        public override void Application_Starting()
        {
            ContainerAdapter.RegisterType <IApplicationContext, ApplicationContext>();

            TaskManager
            .Include <ConfigTask>()
            .Include <ResourceTask>();

            Type WebPageType = typeof(WebPageBase);

            PrecompliedViewEngine.Regist(BuildManager.GetReferencedAssemblies().Cast <Assembly>().SelectMany(assembly => assembly.GetTypes()));
        }
Ejemplo n.º 2
0
        public override void Application_Starting()
        {
            ModelBinders.Binders.Add(typeof(WidgetBase), new WidgetBinder());

            var  routes          = new List <RouteDescriptor>();
            Type plugBaseType    = typeof(PluginBase);
            Type widgetModelType = typeof(WidgetBase);
            var  types           = BuildManager.GetReferencedAssemblies().Cast <Assembly>().SelectMany(assembly => assembly.GetTypes()).ToArray();

            types.Each(p =>
            {
                if (plugBaseType.IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface)
                {
                    var plug = Activator.CreateInstance(p) as PluginBase;
                    if (plug != null)
                    {
                        var moduleRoutes = plug.RegistRoute();
                        if (moduleRoutes != null)
                        {
                            var routeArray = moduleRoutes.ToArray();
                            if (routeArray.Length > 0)
                            {
                                routes.AddRange(routeArray);
                            }
                        }
                        plug.Excute();
                    }
                }
                else if (widgetModelType.IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface && !WidgetBase.KnownWidgetModel.ContainsKey(p.FullName))
                {
                    lock (WidgetBase.KnownWidgetModel)
                    {
                        WidgetBase.KnownWidgetModel.Add(p.FullName, p);
                    }
                }
            });
            PrecompliedViewEngine.Regist(types);
            RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.OrderByDescending(m => m.Priority).Each(m => RouteTable.Routes.MapRoute(m.RouteName, m.Url, m.Defaults, m.Constraints, m.Namespaces));
            ContainerAdapter.RegisterType <IUserService, UserService>();
            ContainerAdapter.RegisterType <IDataDictionaryService, DataDictionaryService>();
            ContainerAdapter.RegisterType <ILanguageService, LanguageService>();
            ContainerAdapter.RegisterType <IAuthorizer, DefaultAuthorizer>();
            ContainerAdapter.RegisterType <IApplicationContext, CMSApplicationContext>(DependencyLifeTime.PerRequest);

            //DisplayViewSupport.SupportMobileView();
            //DisplayViewSupport.SupportIEView();
        }