当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.GetValue方法代码示例

本文整理汇总了C#中Configuration.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.GetValue方法的具体用法?C# Configuration.GetValue怎么用?C# Configuration.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Configuration的用法示例。


在下文中一共展示了Configuration.GetValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CMatchInfo

        /// <summary>
        /// Initializes the underlying <see cref="MatchInfo"/> with values provided by a <see cref="Configuration"/>
        /// and associates the <see cref="MatchInfo"/> with the given <see cref="ControllerInformation"/>.
        /// </summary>
        /// <param name="config">The <see cref="Configuration"/> to load settings from.</param>
        /// <param name="controllerInfos">A variable number of <see cref="ControllerInformation"/>
        /// to associate with.</param>
        /// <exception cref="ControllerIncompatibleException">A controller is not designed for the
        /// configured <see cref="GameMode"/>.</exception>
        public CMatchInfo(Configuration config, params ControllerInformation[] controllerInfos)
        {
            //Get the game mode from the Configuration.
            DetermineGameMode(config);

            //Make sure all of the controllers are compatible with the given game mode.
            foreach (var controllerInfo in controllerInfos)
            {
                if (!controllerInfo.Capabilities.CompatibleWith(gameMode))
                {
                    throw new ControllerIncompatibleException(controllerInfo, gameMode);
                }
            }

            this.controllerNames = new List<string>();
            foreach (var controllerInfo in controllerInfos)
            {
                this.controllerNames.Add(controllerInfo.ToString());
            }

            //Configuration setting for a list of ships that the controllers start with.
            initShips = new ShipList(config.GetList<int>("mbc_ship_sizes").ToArray());

            //Configuration setting for the size of the field.
            fieldSize = new Coordinates(
                config.GetValue<int>("mbc_field_width"),
                config.GetValue<int>("mbc_field_height"));

            //Configuration setting for the amount of time a controller is allowed per method invoke.
            methodTimeLimit = config.GetValue<int>("mbc_timeout");
        }
开发者ID:aiclub,项目名称:Mohawk_Battleship,代码行数:40,代码来源:CMatchInfo.cs

示例2: CheckConfig

		protected void CheckConfig(Configuration cf)
		{
			IDictionaryEnumerator en = _values.GetEnumerator();
			while (en.MoveNext())
			{
				string key = (string) en.Key;
				Assert.AreEqual(en.Value, cf.GetValue(key), key);
				Assert.AreEqual(en.Value.GetType(), cf.GetValue(key).GetType(), key + " type");
			}
		}
开发者ID:ststeiger,项目名称:SyslogServer,代码行数:10,代码来源:ConfigurationTest.cs

示例3: CMatchInfo

        /// <summary>
        /// Initializes the underlying <see cref="MatchInfo"/> with values provided by a <see cref="Configuration"/>
        /// and associates the <see cref="MatchInfo"/> with the given <see cref="ControllerInformation"/>.
        /// </summary>
        /// <param name="config">The <see cref="Configuration"/> to load settings from.</param>
        /// <param name="controllerNames">A variable number of <see cref="ControllerInformation"/>
        /// to associate with.</param>
        /// <exception cref="ControllerIncompatibleException">A controller is not designed for the
        /// configured <see cref="GameMode"/>.</exception>
        public CMatchInfo(Configuration config)
        {
            //Get the game mode from the Configuration.
            DetermineGameMode(config);

            this.controllerNames = new List<string>();

            //Configuration setting for a list of ships that the controllers start with.
            initShips = new ShipList(config.GetList<int>("mbc_ship_sizes").ToArray());

            //Configuration setting for the size of the field.
            fieldSize = new Coordinates(
                config.GetValue<int>("mbc_field_width"),
                config.GetValue<int>("mbc_field_height"));

            //Configuration setting for the amount of time a controller is allowed per method invoke.
            methodTimeLimit = config.GetValue<int>("mbc_timeout");
        }
开发者ID:J0RD1E,项目名称:Mohawk_Battleship,代码行数:27,代码来源:CMatchInfo.cs

示例4: DetermineGameMode

 private void DetermineGameMode(Configuration config)
 {
     gameMode = 0;
     foreach (var gmStr in config.GetValue<List<GameMode>>("mbc_game_mode"))
     {
         gameMode |= gmStr;
         if (gmStr == GameMode.Salvo || gmStr == GameMode.Powered || gmStr == GameMode.Teams)
         {
             throw new NotImplementedException("The "+gmStr.ToString()+" game mode is not supported.");
         }
     }
 }
开发者ID:aiclub,项目名称:Mohawk_Battleship,代码行数:12,代码来源:CMatchInfo.cs

示例5: MainWindow

        /// <summary>
        /// Constructor for the MainWindow. Collapses the collapseable elements of the WPF application.
        /// </summary>
        public MainWindow()
        {
            Configuration.Initialize(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\MBC Data");
            InitializeComponent();
            centerConsoleBorder.Visibility = System.Windows.Visibility.Collapsed;
            advTabs.Visibility = System.Windows.Visibility.Collapsed;

            configuration = Configuration.Global;

            availableControllers = ControllerSkeleton.LoadControllerFolder(
                configuration.GetValue<string>("app_data_root") + "controllers");
            availableControllers.AddRange(ControllerSkeleton.LoadControllerFolder(Environment.CurrentDirectory + "\\..\\bots"));

            //currentMatch = new ControlledMatch(configuration, availableControllers.ToArray());

            UpdateLayout();
        }
开发者ID:aiclub,项目名称:Mohawk_Battleship,代码行数:20,代码来源:MainWindow.xaml.cs

示例6: Init

        private void Init(Configuration conf, params ControllerInformation[] controllersToLoad)
        {
            this.conf = conf;
            //Get the game info from the Configuration.
            //Expecting an exception to be thrown here if a controller isn't compatible with the configured game mode.
            info = new CMatchInfo(conf, controllersToLoad);

            //Create and register the controllers to load.
            GenerateControllers(controllersToLoad);
            RegisterControllers();
            FormOpponents();

            //Configuration setting for the number of rounds this Match will perform.
            roundList = new List<Round>();
            targetRounds = conf.GetValue<int>("mbc_match_rounds");
            roundIteration = -1;
            inProgress = true;

            //Make a thread for this Match.
            runningThread = new Thread(PlayLoop);
            sleepHandle = new AutoResetEvent(false);
            isRunning = false;
            delay = 0;

            //Configuration setting for round playing behaviour, given a number of rounds.
            switch (conf.GetValue<string>("mbc_match_rounds_mode"))
            {
                case "all":
                    roundPlay = PlayMode.AllRounds;
                    break;

                case "first to":
                    roundPlay = PlayMode.FirstTo;
                    break;

                default:
                    conf.SetValue("mbc_match_rounds_mode", "all");
                    break;
            }
        }
开发者ID:J0RD1E,项目名称:Mohawk_Battleship,代码行数:40,代码来源:Match.cs

示例7: SetConfiguration

        public void SetConfiguration(Configuration config)
        {
            Config = config;
            var newConfig = new MatchConfig();
            newConfig.FieldSize = new Coordinates(Config.GetValue<int>("mbc_field_width"), Config.GetValue<int>("mbc_field_height"));
            newConfig.NumberOfRounds = Config.GetValue<int>("mbc_match_rounds");

            var initShips = new ShipList();
            foreach (var length in Config.GetList<int>("mbc_ship_sizes"))
            {
                initShips.Add(new Ship(length));
            }
            newConfig.StartingShips = initShips;

            newConfig.TimeLimit = Config.GetValue<int>("mbc_player_timeout");

            newConfig.GameMode = 0;
            foreach (var mode in Config.GetList<GameMode>("mbc_game_mode"))
            {
                newConfig.GameMode |= mode;
            }
            if (!newConfig.GameMode.HasFlag(GameMode.Classic))
            {
                throw new NotImplementedException("The " + newConfig.GameMode.ToString() + " game mode is not supported.");
            }
            newConfig.Random = new Random();
            ApplyEvent(new MatchConfigChangedEvent(newConfig));
        }
开发者ID:aiclub,项目名称:Mohawk_Battleship,代码行数:28,代码来源:ActiveMatch.cs

示例8: ApplyParameters

        /// <summary>
        /// Applies a configuration to the match.
        /// </summary>
        /// <param name="conf"></param>
        private void ApplyParameters(Configuration conf)
        {
            fieldSize = new Coordinates(conf.GetValue<int>("mbc_field_width"), conf.GetValue<int>("mbc_field_height"));
            numberOfRounds = conf.GetValue<int>("mbc_match_rounds");

            startingShips = ShipList.ShipsFromLengths(conf.GetList<int>("mbc_ship_sizes"));
            timeLimit = conf.GetValue<int>("mbc_player_timeout");

            gameModes = conf.GetList<GameMode>("mbc_game_mode");
        }
开发者ID:aiclub,项目名称:Mohawk_Battleship,代码行数:14,代码来源:Match_New.cs

示例9: GetObjectValueTest

        public void GetObjectValueTest()
        {
            var config = new Configuration(_ => ConfigSource);
            config.Read("main");

            var value = config.GetValue("ssh_client.status");
            Assert.IsTrue(value is bool);
            Assert.AreEqual(true, value);

            value = config.GetValue("ssh_client.welcomeMessage");
            Assert.AreEqual(null, value);
        }
开发者ID:mujing,项目名称:OGS.HOCON,代码行数:12,代码来源:ConfigurationTests.cs


注:本文中的Configuration.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。