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

FastSetProperty() private method

Sets a property value and attributes, or adds a new property if it doesn't already exist. Any existing attributes are ignored (and not modified).
private FastSetProperty ( object key, object value, PropertyAttributes attributes = PropertyAttributes.Sealed, bool overwriteAttributes = false ) : void
key object The property key (either a string or a Symbol).
value object The intended value of the property.
attributes PropertyAttributes Attributes that indicate whether the property is writable, /// configurable and enumerable.
overwriteAttributes bool Indicates whether to overwrite any existing attributes.
return void
        internal void FastSetProperty(object key, object value, PropertyAttributes attributes = PropertyAttributes.Sealed, bool overwriteAttributes = false)
        {
            int index = this.schema.GetPropertyIndex(key);
            if (index < 0)
            {
                // The property is doesn't exist - add a new property.
                AddProperty(key, value, attributes, false);
                return;
            }
            if (overwriteAttributes == true)
                this.schema = this.schema.SetPropertyAttributes(key, attributes);
            this.propertyValues[index] = value;
        }

Usage Example

示例#1
0
        public static ObjectInstance Freeze(ObjectInstance obj)
        {
            var properties = new List <PropertyNameAndValue>();

            foreach (var property in obj.Properties)
            {
                properties.Add(property);
            }
            foreach (var property in properties)
            {
                obj.FastSetProperty(property.Key, property.Value,
                                    property.Attributes & ~(PropertyAttributes.NonEnumerable), overwriteAttributes: true);
            }
            obj.IsExtensible = false;
            return(obj);
        }
All Usage Examples Of Jurassic.Library.ObjectInstance::FastSetProperty