ParameterNullOrEmpty() 정적인 개인적인 메소드

static private ParameterNullOrEmpty ( string parameter ) : ArgumentException
parameter string
리턴 System.ArgumentException
예제 #1
0
 public void SaveAs(string filename, ConfigurationSaveMode saveMode, bool forceSaveAll)
 {
     if (string.IsNullOrEmpty(filename))
     {
         throw ExceptionUtil.ParameterNullOrEmpty("filename");
     }
     this.SaveAsImpl(filename, saveMode, forceSaveAll);
 }
예제 #2
0
 public RegexStringValidator(string regex)
 {
     if (string.IsNullOrEmpty(regex))
     {
         throw ExceptionUtil.ParameterNullOrEmpty("regex");
     }
     this._expression = regex;
     this._regex      = new Regex(regex, RegexOptions.Compiled);
 }
        public ConfigurationSectionGroup Get(string name)
        {
            this.VerifyIsAttachedToConfigRecord();
            if (string.IsNullOrEmpty(name))
            {
                throw ExceptionUtil.ParameterNullOrEmpty("name");
            }
            if (name.IndexOf('/') >= 0)
            {
                return(null);
            }
            string configKey = BaseConfigurationRecord.CombineConfigKey(this._configSectionGroup.SectionGroupName, name);

            return(this._configRecord.GetSectionGroup(configKey));
        }
        public ConfigurationSection Get(string name)
        {
            VerifyIsAttachedToConfigRecord();

            // validate name
            if (string.IsNullOrEmpty(name))
            {
                throw ExceptionUtil.ParameterNullOrEmpty(nameof(name));
            }

            // prevent GetConfig from returning config not in this collection
            if (name.IndexOf('/') >= 0)
            {
                return(null);
            }

            // get the section from the config record
            string configKey = BaseConfigurationRecord.CombineConfigKey(_configSectionGroup.SectionGroupName, name);

            return((ConfigurationSection)_configRecord.GetSection(configKey));
        }
        public ConfigurationSectionGroup Get(string name)
        {
            VerifyIsAttachedToConfigRecord();

            // validate name
            if (string.IsNullOrEmpty(name))
            {
                throw ExceptionUtil.ParameterNullOrEmpty(nameof(name));
            }

            // prevent GetConfig from returning config not in this collection
            if (name.IndexOf('/') >= 0) // string.Contains(char) is .NetCore2.1+ specific
            {
                return(null);
            }

            // get the section group
            string configKey = BaseConfigurationRecord.CombineConfigKey(_configSectionGroup.SectionGroupName, name);

            return(_configRecord.GetSectionGroup(configKey));
        }
예제 #6
0
        internal static Configuration OpenExeConfiguration(ConfigurationFileMap fileMap, bool isMachine,
                                                           ConfigurationUserLevel userLevel, string exePath)
        {
            // validate userLevel argument
            switch (userLevel)
            {
            case ConfigurationUserLevel.None:
            case ConfigurationUserLevel.PerUserRoaming:
            case ConfigurationUserLevel.PerUserRoamingAndLocal:
                break;

            default:
                throw ExceptionUtil.ParameterInvalid(nameof(userLevel));
            }

            // validate fileMap arguments
            if (fileMap != null)
            {
                if (string.IsNullOrEmpty(fileMap.MachineConfigFilename))
                {
                    throw ExceptionUtil.ParameterNullOrEmpty(nameof(fileMap) + "." + nameof(fileMap.MachineConfigFilename));
                }

                ExeConfigurationFileMap exeFileMap = fileMap as ExeConfigurationFileMap;
                if (exeFileMap != null)
                {
                    switch (userLevel)
                    {
                    case ConfigurationUserLevel.None:
                        if (string.IsNullOrEmpty(exeFileMap.ExeConfigFilename))
                        {
                            throw ExceptionUtil.ParameterNullOrEmpty(nameof(fileMap) + "." + nameof(exeFileMap.ExeConfigFilename));
                        }
                        break;

                    case ConfigurationUserLevel.PerUserRoaming:
                        if (string.IsNullOrEmpty(exeFileMap.RoamingUserConfigFilename))
                        {
                            throw ExceptionUtil.ParameterNullOrEmpty(nameof(fileMap) + "." + nameof(exeFileMap.RoamingUserConfigFilename));
                        }
                        goto case ConfigurationUserLevel.None;

                    case ConfigurationUserLevel.PerUserRoamingAndLocal:
                        if (string.IsNullOrEmpty(exeFileMap.LocalUserConfigFilename))
                        {
                            throw ExceptionUtil.ParameterNullOrEmpty(nameof(fileMap) + "." + nameof(exeFileMap.LocalUserConfigFilename));
                        }
                        goto case ConfigurationUserLevel.PerUserRoaming;
                    }
                }
            }

            string configPath = null;

            if (isMachine)
            {
                configPath = MachineConfigPath;
            }
            else
            {
                switch (userLevel)
                {
                case ConfigurationUserLevel.None:
                    configPath = ExeConfigPath;
                    break;

                case ConfigurationUserLevel.PerUserRoaming:
                    configPath = RoamingUserConfigPath;
                    break;

                case ConfigurationUserLevel.PerUserRoamingAndLocal:
                    configPath = LocalUserConfigPath;
                    break;
                }
            }

            Configuration configuration = new Configuration(null, typeof(ClientConfigurationHost), fileMap, exePath, configPath);

            return(configuration);
        }
        internal static System.Configuration.Configuration OpenExeConfiguration(ConfigurationFileMap fileMap, bool isMachine, ConfigurationUserLevel userLevel, string exePath)
        {
            ExeConfigurationFileMap map;
            string str;
            ConfigurationUserLevel level = userLevel;

            if (((level != ConfigurationUserLevel.None) && (level != ConfigurationUserLevel.PerUserRoaming)) && (level != ConfigurationUserLevel.PerUserRoamingAndLocal))
            {
                throw ExceptionUtil.ParameterInvalid("userLevel");
            }
            if (fileMap != null)
            {
                if (string.IsNullOrEmpty(fileMap.MachineConfigFilename))
                {
                    throw ExceptionUtil.ParameterNullOrEmpty("fileMap.MachineConfigFilename");
                }
                map = fileMap as ExeConfigurationFileMap;
                if (map != null)
                {
                    switch (userLevel)
                    {
                    case ConfigurationUserLevel.None:
                        goto Label_0059;

                    case ConfigurationUserLevel.PerUserRoaming:
                        goto Label_0071;

                    case ConfigurationUserLevel.PerUserRoamingAndLocal:
                        if (string.IsNullOrEmpty(map.LocalUserConfigFilename))
                        {
                            throw ExceptionUtil.ParameterNullOrEmpty("fileMap.LocalUserConfigFilename");
                        }
                        goto Label_0071;
                    }
                }
            }
            goto Label_00A1;
Label_0059:
            if (!string.IsNullOrEmpty(map.ExeConfigFilename))
            {
                goto Label_00A1;
            }
            throw ExceptionUtil.ParameterNullOrEmpty("fileMap.ExeConfigFilename");
Label_0071:
            if (!string.IsNullOrEmpty(map.RoamingUserConfigFilename))
            {
                goto Label_0059;
            }
            throw ExceptionUtil.ParameterNullOrEmpty("fileMap.RoamingUserConfigFilename");
Label_00A1:
            str = null;
            if (isMachine)
            {
                str = "MACHINE";
            }
            else
            {
                switch (userLevel)
                {
                case ConfigurationUserLevel.None:
                    str = "MACHINE/EXE";
                    break;

                case ConfigurationUserLevel.PerUserRoaming:
                    str = "MACHINE/EXE/ROAMING_USER";
                    break;

                case ConfigurationUserLevel.PerUserRoamingAndLocal:
                    str = "MACHINE/EXE/ROAMING_USER/LOCAL_USER";
                    break;
                }
            }
            return(new System.Configuration.Configuration(null, typeof(ClientConfigurationHost), new object[] { fileMap, exePath, str }));
        }