Exemple #1
0
        public string Save(AppConfigData data)
        {
            string isValid = data.CheckValid();

            if (!string.IsNullOrEmpty(isValid))
            {
                return(isValid);
            }

            ConfigurationManager.RefreshSection(data.GetType().Name);
            Configuration config =
                ConfigurationManager
                .OpenExeConfiguration(ConfigurationUserLevel.None);
            AppConfigData section = config.Sections[data.GetType().Name] as AppConfigData;

            if (section == null)
            {
                config.Sections.Add(data.GetType().Name, data);
            }
            else
            {
                section.CopyFrom(data);
            }

            config.Save(ConfigurationSaveMode.Minimal);
            return(string.Empty);
        }
Exemple #2
0
        public override void CopyFrom(AppConfigData sourceData)
        {
            NuGetData data = sourceData as NuGetData;

            this.ExePath        = data.ExePath;
            this.PackageSources = data.PackageSources;
        }
Exemple #3
0
        public AppConfigData GetData <T>() where T : AppConfigData
        {
            ConfigurationManager.RefreshSection(typeof(T).Name);
            Configuration config =
                ConfigurationManager
                .OpenExeConfiguration(ConfigurationUserLevel.None);
            AppConfigData data = config.GetSection(typeof(T).Name) as AppConfigData;

            return(data);
        }
 public abstract void CopyFrom(AppConfigData sourceData);