Ejemplo n.º 1
0
        /// <summary>
        /// Overriden. Returns a property descriptor.
        /// </summary>
        /// <remarks>
        /// Tries to resolve proeprty in the following order:
        ///
        /// 1. OwnProperty for the current scope
        /// 2. Any property from the bag (if specified).
        /// 3. A property from scopes hierarchy.
        /// </remarks>
        /// <param name="index">Property name.</param>
        /// <returns>Descriptor</returns>
        public override Descriptor GetDescriptor(string index)
        {
            Descriptor own, d;

            if ((own = base.GetDescriptor(index)) != null && own.Owner == this)
            {
                return(own);
            }

            if (bag != null && (d = bag.GetDescriptor(index)) != null)
            {
                return(d);
            }

            return(own);
        }
Ejemplo n.º 2
0
        public virtual Descriptor GetDescriptor(string index)
        {
            Descriptor result;

            if (properties.TryGet(index, out result))
            {
                return(result);
            }

            // Prototype always a JsObject, (JsNull.Instance is also an object and next call will return null in case of null)
            if ((result = Prototype.GetDescriptor(index)) != null)
            {
                properties.Put(index, result); // cache descriptior
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Overriden. Returns a property descriptor.
        /// </summary>
        /// <remarks>
        /// Tries to resolve proeprty in the following order:
        ///
        /// 1. OwnProperty for the current scope
        /// 2. Any property from the bag (if specified).
        /// 3. A property from scopes hierarchy.
        ///
        /// A proeprty from the bag will be added as a link to the current scope.
        /// </remarks>
        /// <param name="index">Property name.</param>
        /// <returns>Descriptor</returns>
        public override Descriptor GetDescriptor(string index)
        {
            Descriptor own, d;

            if ((own = base.GetDescriptor(index)) != null && own.Owner == this)
            {
                return(own);
            }

            if (bag != null && (d = bag.GetDescriptor(index)) != null)
            {
                Descriptor link = new LinkedDescriptor(this, d.Name, d, bag);
                DefineOwnProperty(link);
                return(link);
            }

            return(own);
        }