Beispiel #1
0
        public static Player Parse(SpeedrunComClient client, dynamic playerElement)
        {
            var player = new Player();

            var properties = playerElement.Properties as IDictionary<string, dynamic>;

            if (properties.ContainsKey("uri"))
            {
                if (playerElement.rel as string == "user")
                {
                    player.UserID = playerElement.id as string;
                    player.user = new Lazy<User>(() => client.Users.GetUser(player.UserID));
                    player.guest = new Lazy<Guest>(() => null);
                }
                else
                {
                    player.GuestName = playerElement.name as string;
                    player.guest = new Lazy<Guest>(() => client.Guests.GetGuest(player.GuestName));
                    player.user = new Lazy<User>(() => null);
                }
            }
            else
            {
                if (playerElement.rel as string == "user")
                {
                    var user = User.Parse(client, playerElement) as User;
                    player.user = new Lazy<User>(() => user);
                    player.UserID = user.ID;
                    player.guest = new Lazy<Guest>(() => null);
                }
                else
                {
                    var guest = Guest.Parse(client, playerElement) as Guest;
                    player.guest = new Lazy<Guest>(() => guest);
                    player.GuestName = guest.Name;
                    player.user = new Lazy<User>(() => null);
                }
            }

            return player;
        }