コード例 #1
0
        public static GameMasterSettingsConfiguration LoadSettingsFromFile(string path)
        {
            GameMasterSettings settings = null;

            try
            {
                using (StreamReader reader = new StreamReader(path))
                {
                    var xmlReader  = XmlReader.Create(reader);
                    var serializer = new XmlSerializer(typeof(GameMasterSettings));
                    if (serializer.CanDeserialize(xmlReader))
                    {
                        settings = (GameMasterSettings)serializer.Deserialize(xmlReader);
                        var errors = Validator.ValidateSettings(new GameMasterSettingsConfiguration(settings));
                        if (!string.IsNullOrEmpty(errors))
                        {
                            ConsoleWriter.Error(Constants.ERRORS_WHILE_PARSING_XML);
                            ConsoleWriter.Show(errors);
                            return(null);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ConsoleWriter.Error(Constants.UNEXPECTED_ERROR + e.Message);
                ConsoleWriter.Show(e.StackTrace);
            }
            return(new GameMasterSettingsConfiguration(settings));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            AgentCommandLineOptions options  = CommandLineParser.ParseArgs <AgentCommandLineOptions>(args, new AgentCommandLineOptions());
            GameMasterSettings      settings = Configuration.FromFile <GameMasterSettings>(options.Conf);
            GameMasterClient        client   = new GameMasterClient(new Connection(options.Address, options.Port), settings,
                                                                    new Logger(UniqueNameGenerator.GetUniqueName(settings.GameDefinition.GameName)), new Game(), new Ranking());

            client.Connect();
            client.Disconnect();
        }