Exemplo n.º 1
0
        public ObjectInstance GetOrCreate(string key)
        {
            if (OwnValues.TryGetValue(key, out var property) == false)
            {
                property = GenerateProperty(key);

                OwnValues[key] = property;
                Deletes?.Remove(key);
            }

            return(property.Value.AsObject());

            BlittableObjectProperty GenerateProperty(string propertyName)
            {
                var propertyIndex = Blittable.GetPropertyIndex(propertyName);

                var prop = new BlittableObjectProperty(this, propertyName);

                if (propertyIndex == -1)
                {
                    prop.Value = new ObjectInstance(Engine)
                    {
                        Extensible = true
                    };
                }

                return(prop);
            }
        }
Exemplo n.º 2
0
        public ObjectInstance GetOrCreate(JsValue key)
        {
            BlittableObjectProperty property = default;

            if (OwnValues?.TryGetValue(key, out property) == true &&
                property != null)
            {
                return(property.Value.AsObject());
            }

            property = GenerateProperty(key.AsString());

            OwnValues ??= new Dictionary <JsValue, BlittableObjectProperty>(Blittable.Count);

            OwnValues[key] = property;
            Deletes?.Remove(key);

            return(property.Value.AsObject());

            BlittableObjectProperty GenerateProperty(string propertyName)
            {
                var propertyIndex = Blittable.GetPropertyIndex(propertyName);

                var prop = new BlittableObjectProperty(this, propertyName);

                if (propertyIndex == -1)
                {
                    prop.Value = new ObjectInstance(Engine);
                }

                return(prop);
            }
        }
Exemplo n.º 3
0
        public ObjectInstance GetOrCreate(string key)
        {
            BlittableObjectProperty value;

            if (OwnValues.TryGetValue(key, out value) == false)
            {
                var propertyIndex = Blittable.GetPropertyIndex(key);
                value = new BlittableObjectProperty(this, key);
                if (propertyIndex == -1)
                {
                    value.Value = new JsValue(new ObjectInstance(Engine));
                }
                OwnValues[key] = value;
                Deletes?.Remove(key);
            }
            return(value.Value.AsObject());
        }