コード例 #1
0
        /// <summary>
        /// Copy the contents of the source settings into this settings
        /// </summary>
        /// <param name="sourceSettings"></param>
        public void CopyFrom(SettingsPersisterHelper sourceSettings, bool recursive, bool overWrite)
        {
            // copy root-level values (to work with types generically we need references
            // to the underlying settings persister objects)
            ISettingsPersister source      = sourceSettings.SettingsPersister;
            ISettingsPersister destination = SettingsPersister;

            foreach (string name in source.GetNames())
            {
                if (overWrite || destination.Get(name) == null)
                {
                    destination.Set(name, source.Get(name));
                }
            }

            // if this is recursive then copy all of the sub-settings
            if (recursive)
            {
                foreach (string subSetting in sourceSettings.GetSubSettingNames())
                {
                    using (SettingsPersisterHelper
                           sourceSubSetting = sourceSettings.GetSubSettings(subSetting),
                           destinationSubSetting = this.GetSubSettings(subSetting))
                    {
                        destinationSubSetting.CopyFrom(sourceSubSetting, recursive, overWrite);
                    }
                }
            }
        }
コード例 #2
0
 public bool HasValue(string name)
 {
     return(settingsPersister.Get(name) != null);
 }