Esempio n. 1
0
        public override bool Open(string sectionName = null, string fileName = null, SysConf.ConfigurationUserLevel userLevel = SysConf.ConfigurationUserLevel.None)
        {
            base.Open(sectionName, fileName, userLevel);

            if (Opened)
            {
                _accessedSections.Add(DefaultClientSection);

                if (!DefaultClientSection.SectionInformation.IsProtected)
                {
                    Save();
                }
            }

            return(Opened);
        }
Esempio n. 2
0
        /// <summary>
        /// Process th e
        /// </summary>
        /// <param name="userLevel"></param>
        /// <returns></returns>
        bool IProcessConfiguration.ProcessConfiguration(System.Configuration.ConfigurationUserLevel userLevel)
        {
            try
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(userLevel);

                if (!config.HasFile)
                {
                    return(true);
                }

                ConfigurationSection tempSection = null;
                ScaffoldSection      section     = null;

                try
                {
                    tempSection = config.GetSection("scaffold");
                    section     = tempSection as ScaffoldSection;
                }
                catch (ConfigurationException e)
                {
                    Output.Error(ScaffoldResources.ProblemLoadingExeConfiguration(e.Message));
                }

                if (section == null)
                {
                    if (tempSection != null)
                    {
                        Output.Warning(ScaffoldResources.ScaffoldSectionPresentButWrongType);
                    }

                    // Otherwise the section just isn't there
                    return(true);
                }

                GetBoolSetting(section, "Verbose", ref verbose);
                GetBoolSetting(section, "NoRemoting", ref noRemoting);
            }
            catch (ConfigurationErrorsException)
            {
                Output.Warning(ScaffoldResources.ApplicationConfigurationCouldNotBeLoaded);
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        public virtual bool Open(string sectionName = null, string fileName = null, SysConf.ConfigurationUserLevel userLevel = SysConf.ConfigurationUserLevel.None)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                Configuration = SysConf.ConfigurationManager.OpenExeConfiguration(userLevel);
            }
            else
            {
                var configurationFileMap = new SysConf.ExeConfigurationFileMap();
                configurationFileMap.ExeConfigFilename = fileName;
                Configuration = SysConf.ConfigurationManager.OpenMappedExeConfiguration(configurationFileMap, userLevel);
            }

            DefaultSection = sectionName ?? "userSettings/" + Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName.Trim()).Replace(".vshost", "") + ".Settings";

            if (DefaultClientSection == null)
            {
                throw new FileLoadException("Could find setting " + DefaultSection + " in file.");
            }

            return(Opened = Configuration != null);
        }
Esempio n. 4
0
 public sc.Configuration OpenMappedExeConfiguration(sc.ExeConfigurationFileMap fileMap,
                                                    sc.ConfigurationUserLevel userLevel, bool preLoad)
 {
     return(sc.ConfigurationManager.OpenMappedExeConfiguration(fileMap, userLevel, preLoad));
 }
Esempio n. 5
0
 public sc.Configuration OpenExeConfiguration(sc.ConfigurationUserLevel userLevel)
 {
     return(sc.ConfigurationManager.OpenExeConfiguration(userLevel));
 }
Esempio n. 6
0
 public IConfiguration OpenConfiguration(DotNetConfiguration.ConfigurationUserLevel userLevel)
 {
     DotNetConfiguration.Configuration configuration = DotNetConfiguration.ConfigurationManager.OpenExeConfiguration(userLevel);
     return(configuration == null ? null : new ConfigurationWrapper(configuration));
 }