コード例 #1
0
        public IPlayerArray Append(IPlayerArray NewPlayers)
        {
            PlayerArray playerArray = new PlayerArray();

            if (NewPlayers == null || NewPlayers.Count == 0)
            {
                return((IPlayerArray)playerArray);
            }
            if (this.Count == 0)
            {
                foreach (IPlayer newPlayer in (IEnumerable <IPlayer>)NewPlayers)
                {
                    playerArray.AddPlayer(newPlayer);
                }
            }
            else
            {
                for (int index = 0; index < NewPlayers.Count; ++index)
                {
                    IPlayer newPlayer = NewPlayers[index];
                    if (!this.HasPlayer(newPlayer.ID))
                    {
                        playerArray.AddPlayer(newPlayer);
                    }
                }
            }
            if (playerArray.Count > 0)
            {
                this.AddRange((IPlayerArray)playerArray);
                this.SortOrder = PlayerSortOrder.Unsorted;
            }
            return((IPlayerArray)playerArray);
        }
コード例 #2
0
        public IPlayerArray Downgrade()
        {
            PlayerArray playerArray = new PlayerArray();

            foreach (ITournPlayer tournPlayer in (List <ITournPlayer>) this)
            {
                playerArray.AddPlayer((IPlayer)tournPlayer);
            }
            return((IPlayerArray)playerArray);
        }
コード例 #3
0
        public static void WriteToFile(IPlayerArray players, string filename, bool overwrite)
        {
            PlayerArray playerArray1 = new PlayerArray();
            PlayerArray playerArray2 = new PlayerArray();
            PlayerArray playerArray3 = new PlayerArray();

            if (File.Exists(filename) && !overwrite)
            {
                playerArray1.Append(PlayerArray.LoadFromFile(filename));
                playerArray1.SortByID();
                foreach (Player player in (IEnumerable <IPlayer>)players)
                {
                    if (playerArray1.FindById(player.ID) == null)
                    {
                        if (Engine.GetCossyIdType(player.ID) == Engine.CossyIdType.CossyId)
                        {
                            playerArray2.AddPlayer((IPlayer)player);
                        }
                        else
                        {
                            playerArray3.Add((IPlayer)player);
                        }
                    }
                }
                playerArray2.Append((IPlayerArray)playerArray1);
            }
            else
            {
                foreach (Player player in (IEnumerable <IPlayer>)players)
                {
                    if (Engine.GetCossyIdType(player.ID) == Engine.CossyIdType.CossyId)
                    {
                        playerArray2.AddPlayer((IPlayer)player);
                    }
                    else
                    {
                        playerArray3.Add((IPlayer)player);
                    }
                }
            }
            if (playerArray3.Count > 0)
            {
                PlayerArray.WriterPlayersToCsv(Path.Combine(Settings.DataStorageFolder, string.Format("Invalid COSSY IDs {0}.csv", (object)DateTime.Now.ToString("yyyyMMdd"))), (IPlayerArray)playerArray3);
            }
            if (playerArray2.Count == 0)
            {
                return;
            }
            playerArray2.SortByLastname();
            Player[] playerArray4 = new Player[playerArray2.Count];
            playerArray2.CopyTo((IPlayer[])playerArray4, 0);
            Type type = typeof(Player);

            for (int index = 0; index < playerArray4.Length; ++index)
            {
                if (playerArray4[index].GetType() != type)
                {
                    playerArray4[index] = new Player((IPlayer)playerArray4[index]);
                }
            }
            StreamWriter streamWriter = new StreamWriter(filename, false);

            new XmlSerializer(typeof(Player[]), new XmlRootAttribute("PlayerList")).Serialize((TextWriter)streamWriter, (object)playerArray4);
            streamWriter.Close();
            streamWriter.Dispose();
        }