Пример #1
0
        /// <summary>
        /// Saves changes to <see cref="Out"/> to the
        /// given IConfigurationSource.
        /// </summary>
        /// <param name="source">Source to use as the primary source.</param>
        public void SaveChanges(IConfigurationSource <T> source)
        {
            var @base = CreateBaseConfig();
            var mrg   = new T();

            mrg.MergeWith(_primarySource.Config);
            mrg.MergeWith(Out, defaultObject: @base);

            // Copy over the values for all "always serialized" properties
            foreach (var prop in _propertiesAlwaysSerialized
                     .Select(propName => typeof(T).GetProperty(propName)))
            {
                prop.SetValue(mrg, prop.GetValue(Out, null), null);
            }

            source.PartialSave(mrg,
                               GetProperties(@base, _primarySource.Config, PropertyStatus.Changed)
                               .Select(p => p.Name)
                               .Concat(_propertiesAlwaysSerialized)
                               .Except(_propertiesNeverSerialized));
        }