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; }
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); }