コード例 #1
0
ファイル: SessionScope.cs プロジェクト: mizzunet/spike-box
        /// <summary>
        /// Creates a child scope.
        /// </summary>
        /// <param name="prototype">The prototype of the scope to create.</param>
        /// <param name="name">The name of the child to assign.</param>
        /// <returns>A new instance of a child scope.</returns>
        protected override Scope CreateChild(string prototype, string name)
        {
            // Create a new page scope
            try
            {
                var protoref = this.Context.GetPrototype(prototype);
                var instance = new PageScope(name, this, this.Context, protoref);

                // Call the constructor
                instance.Prototype.Get("constructor").Func.Call(instance);

                // Attach the session to this & return
                instance.Put("session", this);
                return instance;
            }
            catch (InvalidCastException ex)
            {
                if (!ex.Message.Contains("Undefined"))
                    throw ex;

                throw new ArgumentException("Unable to create or retrieve the object of type " + prototype + ".");
            }
        }
コード例 #2
0
ファイル: ElementScope.cs プロジェクト: mizzunet/spike-box
 /// <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 ElementScope(string name, PageScope parent, ScriptContext context, ScriptObject prototype)
     : base(name, parent, context, prototype)
 {
 }