コード例 #1
0
        public static ConfigSettingsConfigurationSection GetFromConfig(string sectionName)
        {
            try
            {
                ConfigSettingsConfigurationSection config = (ConfigSettingsConfigurationSection)ConfigurationManager.GetSection(sectionName);

                if (config == null)
                {
                    _log.Error("Could not find ConfigSettingsSection.");
                    throw new ConfigurationErrorsException("Could not find ConfigSettingsSection.");
                }

                return(config);
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Error while reading ConfigSettings from config file: {0}", sectionName, ex);
                throw;
            }
        }
コード例 #2
0
        public ServerInfo(ConfigSettingsConfigurationSection configSection, string serverPackMask, Version version, string trackDirectory, DetailedPlayerInfo serverPlayerInfo)
        {
            if (configSection == null)
            {
                throw new ArgumentNullException("configSection");
            }

            if (serverPackMask == null)
            {
                throw new ArgumentNullException("serverPackMask");
            }

            if (version == null)
            {
                throw new ArgumentNullException("version");
            }

            if (trackDirectory == null)
            {
                throw new ArgumentNullException("trackDirectory");
            }

            if (serverPlayerInfo == null)
            {
                throw new ArgumentNullException("serverPlayerInfo");
            }

            ServerAddress       = configSection.ServerAddress;
            ServerXMLRpcPort    = configSection.ServerXMLRPCPort;
            SuperAdminPassword  = configSection.SuperAdminPassword;
            ServerNation        = configSection.ServerNation;
            ServerLogin         = configSection.ServerLogin;
            ServerLoginPassword = configSection.ServerLoginPassword;
            ServerPackMask      = serverPackMask;
            Version             = version.Clone();
            TrackDirectory      = trackDirectory;
            PlayerInfo          = serverPlayerInfo;
        }