Esempio n. 1
0
        void SetDynamicProperty(string name, object value)
        {
            if (_dynamicFieldMetadata == null)
            {
                BuildFieldMetadata();
            }

            JsonDynamicFieldHelper.SetProperty(_jObject, name, value);
            _dynamicFieldsChanged = true;
        }
Esempio n. 2
0
        /// <inheritdoc />
        /// <remarks>Sets or overrides any dynamic or well-known property.</remarks>
        public override void SetProperty(string name, object value)
        {
            if (this.HasProperty(name))
            {
                base.SetProperty(name, value);
            }
            else if (BinaryAsJObject != null)
            {
                // If the value is the same as what the inherited settings contains, set it to null, thus removing it from the JSON
                var inherited      = this.FindClosestInheritedSettingsFile();
                var inheritedValue = inherited?.GetProperty(name);
                if (inheritedValue != null && inheritedValue.Equals(value))
                {
                    value = null;
                }

                JsonDynamicFieldHelper.SetProperty(BinaryAsJObject, name, value);
                _dynamicFieldsChanged = true;
            }
        }
Esempio n. 3
0
        // ================================================================================= ISupportsAddingFieldsOnTheFly implementation

        bool ISupportsAddingFieldsOnTheFly.AddFields(IEnumerable <FieldMetadata> fields)
        {
            if (BinaryAsJObject == null)
            {
                return(false);
            }

            if (_dynamicFieldMetadata == null)
            {
                BuildDynamicFieldMetadata();
            }

            foreach (var field in fields)
            {
                _dynamicFieldMetadata.Add(field.FieldName, field);
                if (field.FieldSetting != null)
                {
                    JsonDynamicFieldHelper.SetProperty(BinaryAsJObject, field.FieldName, field.FieldSetting.DefaultValue);
                }
            }

            return(true);
        }