Linked descriptor - a link to the particular property (represented by a descriptor) of the particular object.
Inheritance: Descriptor
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.
        ///
        /// 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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs new descriptor
 /// </summary>
 /// <param name="owner">An owner of the new descriptor</param>
 /// <param name="name">A name of the new descriptor</param>
 /// <param name="source">A property descriptor of the target object to which we should link to</param>
 /// <param name="that">A target object to whose property we are linking. This parameter will be
 /// used in the calls to a 'Get' and 'Set' properties of the source descriptor.</param>
 public LinkedDescriptor(JsDictionaryObject owner, string name, Descriptor source, JsDictionaryObject that)
     : base(owner, name)
 {
     if (source.isReference)
     {
         LinkedDescriptor sourceLink = source as LinkedDescriptor;
         d      = sourceLink.d;
         m_that = sourceLink.m_that;
     }
     else
     {
         d = source;
     }
     Enumerable   = true;
     Writable     = true;
     Configurable = true;
     m_that       = that;
 }
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;
        }