/// <summary> /// Constructs a new instance of an <see cref="AppScope"/>. /// </summary> /// <param name="name">The unique name for the scope.</param> /// <param name="parent">The parent scope to attach to the scope.</param> /// <param name="context">The execution context that is used to execute scripts.</param> internal SessionScope(string name, AppScope parent, ScriptContext context) : base(name, parent, context, context.GetPrototype("Session")) { // Create a new channel linked to the session this.SessionChannel = new Channel(context); // When creating, set the current thread channel Channel.Current = this.SessionChannel; }
public App(string virtualDirectory, string localDirectory) { this.fHandlers = new List<IAppHandler>(); if (!virtualDirectory.StartsWith("/")) virtualDirectory = "/" + virtualDirectory; this.Mime = new HttpMimeMap(); this.LocalDirectory = localDirectory; this.VirtualDirectory = virtualDirectory.StartsWith("/") ? virtualDirectory.ToLower() : "/" + virtualDirectory.ToLower(); this.Folder = new AppFolder(this); this.DefaultPages = new List<string>(); this.Active = true; // Generate the key this.Oid = this.GenerateKey(); // Load the configuration from the local directory this.fConfig = AppConfig.Load(this); // Store the list of hosts in the AppDomain var hosts = fConfig.Hosts.ToArray(); AppDomain.CurrentDomain.SetData("hosts", hosts); // Create a new scope and attach it to the context. var context = new ScriptContext(); this.fScope = new AppScope(this, context); // Prepare new handlers var handlers = new IAppHandler[] { new HandlerResource(), new HandlerApp(), new HandlerView(), new HandlerElement(), new HandlerCss(), new HandlerJs() }; // Register other handlers if (handlers != null && handlers.Length > 0) { for (int i = 0; i < handlers.Length; ++i) this.Register(handlers[i]); } // Populate the repositories this.Folder.Invalidate(); }