Jurassic.Library.ObjectInstance.GetOwnPropertyDescriptor C# (CSharp) Method

GetOwnPropertyDescriptor() public method

Gets a descriptor for the property with the given name.
The prototype chain is not searched.
public GetOwnPropertyDescriptor ( object key ) : PropertyDescriptor
key object The property key (either a string or a Symbol).
return PropertyDescriptor
        public PropertyDescriptor GetOwnPropertyDescriptor(object key)
        {
            // Check if the property is an indexed property.
            uint arrayIndex = ArrayInstance.ParseArrayIndex(key);
            if (arrayIndex != uint.MaxValue)
                return GetOwnPropertyDescriptor(arrayIndex);

            // Retrieve information about the property.
            var property = this.schema.GetPropertyIndexAndAttributes(key);
            if (property.Exists == true)
            {
                if (property.IsLength == false)
                    return new PropertyDescriptor(this.propertyValues[property.Index], property.Attributes);

                // The property is the "magic" length property.
                return new PropertyDescriptor(((ArrayInstance)this).Length, property.Attributes);
            }

            // The property doesn't exist.
            return PropertyDescriptor.Undefined;
        }

Same methods

ObjectInstance::GetOwnPropertyDescriptor ( uint index ) : PropertyDescriptor

Usage Example

示例#1
0
        public static ObjectInstance DefineProperty([JSParameter(JSParameterFlags.DoNotConvert)] ObjectInstance obj, string propertyName, [JSParameter(JSParameterFlags.DoNotConvert)] ObjectInstance attributes)
        {
            var defaults   = obj.GetOwnPropertyDescriptor(propertyName);
            var descriptor = PropertyDescriptor.FromObject(attributes, defaults);

            obj.DefineProperty(propertyName, descriptor, true);
            return(obj);
        }
All Usage Examples Of Jurassic.Library.ObjectInstance::GetOwnPropertyDescriptor