public static void LoadApplications(Core core, AppPrimitives primitive, string uri, List<ApplicationEntry> applicationsList) { if (core == null) { throw new NullCoreException(); } #if DEBUG Stopwatch load = new Stopwatch(); load.Start(); #endif foreach (ApplicationEntry ae in applicationsList) { if (!core.LoadedApplication(ae)) { if (ae.SlugMatch(uri)) { try { Assembly assembly = LoadedAssemblies[ae.Id]; Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(Application))) { #if DEBUG long startInit = load.ElapsedTicks; #endif Application newApplication = System.Activator.CreateInstance(type, new object[] { core }) as Application; #if DEBUG if (HttpContext.Current != null && core.Session.SessionMethod != SessionMethods.OAuth) { HttpContext.Current.Response.Write(string.Format("<!-- Activated {1} in {0} -->\r\n", (load.ElapsedTicks - startInit) / 10000000.0, newApplication.Title)); } #endif if (newApplication != null) { if ((newApplication.GetAppPrimitiveSupport() & primitive) == primitive || primitive == AppPrimitives.Any) { newApplication.Initialise(core); core.Template.AddPageAssembly(assembly); if (ae.HasStyleSheet) { VariableCollection styleSheetVariableCollection = core.Template.CreateChild("style_sheet_list"); styleSheetVariableCollection.Parse("URI", @"/styles/applications/" + ae.Key + @".css"); } if (ae.HasJavascript) { VariableCollection javaScriptVariableCollection = core.Template.CreateChild("javascript_list"); javaScriptVariableCollection.Parse("URI", @"/scripts/" + ae.Key + @".js"); } /* Initialise prose class for the application */ core.Prose.AddApplication(ae.Key); } } } } } catch (Exception ex) { //core.Http.Write(ex.ToString() + "<hr />"); // -- DEBUG HERE FOR APPLICATION LOADER -- } } } } #if DEBUG load.Stop(); if (HttpContext.Current != null && core.Session.SessionMethod != SessionMethods.OAuth) { HttpContext.Current.Response.Write(string.Format("<!-- Application.LoadApplications in {0} -->\r\n", load.ElapsedTicks / 10000000.0)); } #endif }
public static void LoadApplication(Core core, AppPrimitives primitive, ApplicationEntry ae) { if (core == null) { throw new NullCoreException(); } if (!core.LoadedApplication(ae)) { Application newApplication = GetApplication(core, primitive, ae); if (newApplication != null) { if ((newApplication.GetAppPrimitiveSupport() & primitive) == primitive || primitive == AppPrimitives.Any) { newApplication.Initialise(core); if (core.Template != null) { core.Template.AddPageAssembly(ae.Assembly); if (ae.HasStyleSheet) { VariableCollection styleSheetVariableCollection = core.Template.CreateChild("style_sheet_list"); styleSheetVariableCollection.Parse("URI", @"/styles/applications/" + ae.Key + @".css"); } if (ae.HasJavascript) { VariableCollection javaScriptVariableCollection = core.Template.CreateChild("javascript_list"); javaScriptVariableCollection.Parse("URI", @"/scripts/" + ae.Key + @".js"); } } /* Initialise prose class for the application */ core.Prose.AddApplication(ae.Key); } } } }