예제 #1
0
        /// <summary>
        /// Adds or replaces a value from a source <see cref="SettingObject"/> with a different schema.
        /// </summary>
        /// <param name="property">
        /// The property for which to add or replace the value.
        /// </param>
        /// <param name="value">
        /// The new value to associate with the property.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="property"/> and/or <paramref name="value"/> are null.
        /// </exception>
        public void AddOrReplaceRaw(SettingProperty property, PValue value)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (Schema.ContainsProperty(property) && property.IsValidValue(value))
            {
                KeyValueMapping[property.Name.Key] = value;
            }
        }
예제 #2
0
        /// <summary>
        /// Gets the <see cref="PValue"/> that is associated with the specified property.
        /// </summary>
        /// <param name="property">
        /// The property to locate.
        /// </param>
        /// <param name="value">
        /// When this method returns, contains the value associated with the specified property,
        /// if the property is found; otherwise, the default <see cref="PValue"/> value.
        /// This parameter is passed uninitialized.
        /// </param>
        /// <returns>
        /// true if this <see cref="SettingObject"/> contains a value for the specified property;
        /// otherwise, false.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="property"/> is null.
        /// </exception>
        public bool TryGetRawValue(SettingProperty property, out PValue value)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            if (Schema.ContainsProperty(property) &&
                Map.TryGetValue(property.Name.Key, out value))
            {
                return(true);
            }
            value = default;
            return(false);
        }