示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#4
0
 public sc.Configuration OpenMappedExeConfiguration(sc.ExeConfigurationFileMap fileMap,
                                                    sc.ConfigurationUserLevel userLevel, bool preLoad)
 {
     return(sc.ConfigurationManager.OpenMappedExeConfiguration(fileMap, userLevel, preLoad));
 }
示例#5
0
 public sc.Configuration OpenExeConfiguration(sc.ConfigurationUserLevel userLevel)
 {
     return(sc.ConfigurationManager.OpenExeConfiguration(userLevel));
 }
示例#6
0
 public IConfiguration OpenConfiguration(DotNetConfiguration.ConfigurationUserLevel userLevel)
 {
     DotNetConfiguration.Configuration configuration = DotNetConfiguration.ConfigurationManager.OpenExeConfiguration(userLevel);
     return(configuration == null ? null : new ConfigurationWrapper(configuration));
 }