Example #1
0
        private static void PopulateTable <T>(DatabaseUpdates mydata)
        {
            List <string> allNames = new List <string>();

            if (typeof(T) == typeof(Collectable))
            {
                foreach (Collectable coll in mydata.GetAllCollectables())
                {
                    allNames.Add(coll.Name);
                }
                foreach (Collectable coll in AppManager.Collectables)
                {
                    if (!allNames.Contains(coll.Name))
                    {
                        mydata.AddCollectable(coll);
                    }
                }
            }
            if (typeof(T) == typeof(Player))
            {
                foreach (Player player in mydata.GetAllPlayers())
                {
                    allNames.Add(player.Name);
                }
                if (!allNames.Contains(AppManager.PlayerName))
                {
                    mydata.AddPlayer(new Player(AppManager.PlayerName));
                }
            }
            if (typeof(T) == typeof(Friend))
            {
                foreach (Friend friend in mydata.GetAllFriends())
                {
                    allNames.Add(friend.Name);
                }
                foreach (Friend friend in AppManager.Friends)
                {
                    if (!allNames.Contains(friend.Name))
                    {
                        mydata.AddFriend(friend);
                    }
                }
            }
        }