public AccountSubModuleAttribute(AppPrimitives primitives, string moduleName, string subModuleName, bool isDefault) { this.moduleName = moduleName; this.subModuleName = subModuleName; this.isDefault = isDefault; this.primitives = primitives; }
public PageHandle(AppPrimitives primitives, string expression, Core.PageHandler pageHandle, int order, bool staticPage) { this.order = order; this.handler = pageHandle; this.expression = expression; this.primitives = primitives; this.staticPage = staticPage; }
public ShowAttribute(string stub, string slug, AppPrimitives primitives, int order) { bool pathIsRegex = false; string path = slug; string clean = string.Empty; if (path.StartsWith(@"^", StringComparison.Ordinal) && path.EndsWith(@"$", StringComparison.Ordinal)) { path = path.Substring(1, path.Length - 2).TrimStart(new char[] { '/' }); if (path.EndsWith("(|/)", StringComparison.Ordinal)) { path = path.Substring(0, path.Length - 4); } clean = path; pathIsRegex = true; } else { clean = path; } if (string.IsNullOrEmpty(stub)) { string[] parts = path.Split(new char[] {'/'}); if (parts.Length > 0) { stub = parts[0]; } else { stub = string.Empty; } } if (!pathIsRegex) { slug = @"^/" + slug + @"(|/)$"; } this.stub = stub; this.slug = slug; this.cleanSlug = clean; this.primitives = primitives; this.order = order; }
public static ApplicationSlug Create(Core core, long applicationId, string slug, string stub, bool isStatic, AppPrimitives primitives, long updatedTime) { if (core == null) { throw new NullCoreException(); } InsertQuery iQuery = new InsertQuery(GetTable(typeof(ApplicationSlug))); iQuery.AddField("slug_stub", stub); iQuery.AddField("slug_slug_ex", slug); iQuery.AddField("application_id", applicationId); iQuery.AddField("slug_primitives", (byte)primitives); iQuery.AddField("slug_static", isStatic); iQuery.AddField("slug_updated_ut", updatedTime); long slugId = core.Db.Query(iQuery); return new ApplicationSlug(core, slugId); }
public static Application GetApplication(Core core, AppPrimitives primitive, ApplicationEntry ae) { if (core == null) { throw new NullCoreException(); } try { Assembly assembly = LoadedAssemblies[ae.Id]; Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(Application))) { Application newApplication = System.Activator.CreateInstance(type, new object[] {core}) as Application; if (newApplication != null) { return newApplication; } } } } catch (Exception ex) { // TODO DEBUG HERE try { core.Email.SendEmail(WebConfigurationManager.AppSettings["error-email"], "An Error occured at " + Hyperlink.Domain + " in Application.cs", "EXCEPTION THROWN:\n" + ex.ToString()); } catch { } } return null; }
public void AddSlug(string stub, string slugEx, AppPrimitives primitives, bool isStatic) { addSlug(new ApplicationSlugInfo(stub, slugEx, primitives, isStatic)); }
public ApplicationSlugInfo(ShowAttribute showattr) { Stub = showattr.Stub; SlugEx = showattr.Slug; Primitives = showattr.Primitives; IsStatic = false; }
public PageSlugAttribute(string pageTitle, AppPrimitives primitive) { this.primitive = primitive; this.pageTitle = pageTitle; }
public void RegisterApplicationPage(AppPrimitives primitives, string expression, Core.PageHandler pageHandle, int order, bool staticPage) { pages.Add(new PageHandle(primitives, expression, pageHandle, order, staticPage)); }
public void RegisterApplicationPage(AppPrimitives primitives, string expression, Core.PageHandler pageHandle, bool staticPage) { // register with a moderately high priority leaving room for higher priority registration // it doesn't matter if two pages have the same priority RegisterApplicationPage(primitives, expression, pageHandle, 8, staticPage); }
public void InvokeApplication(AppPrimitives primitive, object sender, bool staticPage) { LoadApplication(this, sender); #if DEBUG Stopwatch httpTimer = new Stopwatch(); httpTimer.Start(); #endif pages.Sort(); foreach (PageHandle page in pages) { if (staticPage == page.StaticPage) { if ((page.Primitives & primitive) == primitive || primitive == AppPrimitives.Any) { Regex rex = new Regex(page.Expression); //HttpContext.Current.Response.Write("<br />" + page.Expression + " " + PagePath); Match pathMatch = rex.Match(PagePath); if (pathMatch.Success) { //HttpContext.Current.Response.Write(" **match** "); PagePathParts = pathMatch.Groups; #if DEBUG httpTimer.Stop(); HttpContext.Current.Response.Write(string.Format("<!-- Invoke {1} in {0} -->\r\n", httpTimer.ElapsedTicks / 10000000.0, PagePath)); #endif page.Execute(this, sender); return; } } } } Functions.Generate404(); }
public void InvokeApplication(AppPrimitives primitive, object sender) { InvokeApplication(primitive, sender, false); }
public Dictionary<string, PageSlugAttribute> GetPageSlugs(AppPrimitives primitive) { Dictionary<string, PageSlugAttribute> slugs = null; if (PageSlugs != null) { slugs = PageSlugs; } else { slugs = new Dictionary<string, PageSlugAttribute>(StringComparer.Ordinal); } /* Discover page slugs */ Type type = this.GetType(); foreach (MethodInfo mi in type.GetMethods(BindingFlags.Default | BindingFlags.Instance | BindingFlags.NonPublic)) { foreach (Attribute attr in Attribute.GetCustomAttributes(mi, typeof(ShowAttribute))) { if ((((ShowAttribute)attr).Primitives & primitive) == primitive) { foreach (Attribute psAttr in Attribute.GetCustomAttributes(mi, typeof(PageSlugAttribute))) { slugs.Add(((ShowAttribute)attr).CleanSlug, ((PageSlugAttribute)psAttr)); } } } } return slugs; }
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); } } } }
public static ApplicationSlug Create(Core core, long applicationId, string slug, string stub, AppPrimitives primitives) { return Create(core, applicationId, slug, stub, false, primitives, UnixTime.UnixTimeStamp()); }
public HookEventArgs(Core core, AppPrimitives pageType, Primitive owner) { this.core = core; this.pageType = pageType; this.owner = owner; }
public ShowAttribute(string stub, string slug, AppPrimitives primitives) : this(stub, slug, primitives, -1) { }
public ApplicationSlugInfo(string stub, string slugEx, AppPrimitives primitives, bool isStatic) { Stub = stub; SlugEx = slugEx; Primitives = primitives; IsStatic = isStatic; }
public ShowAttribute(string slug, AppPrimitives primitives, int order) : this(null, slug, primitives, order) { }
public ApplicationSlugInfo(StaticShowAttribute showattr) { Stub = showattr.Stub; SlugEx = showattr.Slug; Primitives = AppPrimitives.None; IsStatic = true; }
public AccountSubModuleAttribute(AppPrimitives primitives, string moduleName, string subModuleName) : this(primitives, moduleName, subModuleName, false) { }
public void AddSlug(string stub, string slugEx, AppPrimitives primitives) { addSlug(new ApplicationSlugInfo(stub, slugEx, primitives, false)); }
public AccountModuleAttribute(AppPrimitives primitives, string moduleName) { this.moduleName = moduleName; this.primitives = primitives; }