GetMissingPropertyValue() 보호된 메소드

Retrieves the value of a property which doesn't exist on the object. This method can be overridden to effectively construct properties on the fly. The default behavior is to return undefined.
When overriding, call the base class implementation only if you want to revert to the default behavior.
protected GetMissingPropertyValue ( object key ) : object
key object The property key of the missing property.
리턴 object
예제 #1
0
        /// <summary>
        /// Gets the value of the property with the given name.  The name cannot be an array index.
        /// </summary>
        /// <param name="propertyName"> The name of the property.  The name cannot be an array index. </param>
        /// <param name="thisValue"> The value of the "this" keyword inside a getter. </param>
        /// <returns> The value of the property, or <c>null</c> if the property doesn't exist. </returns>
        /// <remarks> The prototype chain is searched if the property does not exist directly on
        /// this object. </remarks>
        private object GetNamedPropertyValue(string propertyName, ObjectInstance thisValue)
        {
            ObjectInstance prototypeObject = this;
            do
            {
                // Retrieve information about the property.
                var property = prototypeObject.schema.GetPropertyIndexAndAttributes(propertyName);
                if (property.Exists == true)
                {
                    // The property was found!
                    object value = prototypeObject.propertyValues[property.Index];
                    if ((property.Attributes & (PropertyAttributes.IsAccessorProperty | PropertyAttributes.IsLengthProperty)) == 0)
                        return value;

                    // Call the getter if there is one.
                    if (property.IsAccessor == true)
                        return ((PropertyAccessorValue)value).GetValue(thisValue);

                    // Otherwise, the property is the "magic" length property.
                    return ((ArrayInstance)prototypeObject).Length;
                }

                // Traverse the prototype chain.
                prototypeObject = prototypeObject.prototype;
            } while (prototypeObject != null);

            // The property doesn't exist.
            return thisValue.GetMissingPropertyValue(propertyName);
        }
예제 #2
0
        /// <summary>
        /// Gets the value of the property with the given array index.
        /// </summary>
        /// <param name="index"> The array index of the property. </param>
        /// <param name="thisValue"> The value of the "this" keyword inside a getter. </param>
        /// <returns> The value of the property, or <c>null</c> if the property doesn't exist. </returns>
        /// <remarks> The prototype chain is searched if the property does not exist directly on
        /// this object. </remarks>
        private object GetPropertyValue(uint index, ObjectInstance thisValue)
        {
            // Get the descriptor for the property.
            var property = this.GetOwnPropertyDescriptor(index);
            if (property.Exists == true)
            {
                // The property was found!  Call the getter if there is one.
                object value = property.Value;
                var accessor = value as PropertyAccessorValue;
                if (accessor != null)
                    return accessor.GetValue(thisValue);
                return value;
            }

            // The property might exist in the prototype.
            if (this.prototype == null)
                return thisValue.GetMissingPropertyValue(index.ToString());
            return this.prototype.GetPropertyValue(index, thisValue);
        }