Beispiel #1
0
        /// <summary>
        /// Gets the entity using the specified identifier.
        /// </summary>
        /// <param name="AccountId">The account identifier.</param>
        /// <param name="Store">Whether it has to be stored.</param>
        public async Task <Player> Get(string Username, string Password, bool Store = true)
        {
            PlayerDb PlayerDb = await this.Server.Database.Load(Username, Password);

            Player Player = null;

            /* if (Players.Entities.TryGetValue(PlayerDb., out Player))
             * {
             *  return Player;
             * }
             * else */
            {
                if (PlayerDb != null)
                {
                    if (this.Server.Database.Deserialize(PlayerDb, out Player))
                    {
                        if (Store)
                        {
                            this.Add(Player);
                        }

                        return(Player);
                    }
                    else
                    {
                        Log.Error(typeof(Players), "PlayerDb.Deserialize(out Player) != true at Get(" + Username + ", " + Password + ").");
                    }
                }
                else
                {
                    Log.Warning(typeof(Players), "PlayerDb == null at Get(HighId, LowId).");
                }
            }

            return(Player);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the entity using the specified identifier.
        /// </summary>
        /// <param name="AccountId">The account identifier.</param>
        /// <param name="Store">Whether it has to be stored.</param>
        public async Task <Player> Get(string AccountId, bool Store = true)
        {
            PlayerDb PlayerDb = await this.Server.Database.Load(AccountId);

            Player Player = null;

            if (this.Entities.TryGetValue(AccountId, out Player))
            {
                return(Player);
            }
            else
            {
                if (PlayerDb != null)
                {
                    if (this.Server.Database.Deserialize(PlayerDb, out Player))
                    {
                        if (Store)
                        {
                            this.Add(Player);
                        }

                        return(Player);
                    }
                    else
                    {
                        Log.Error(typeof(Players), "PlayerDb.Deserialize(out Player) != true at Get(" + AccountId + ").");
                    }
                }
                else
                {
                    Log.Warning(typeof(Players), "PlayerDb == null at Get(HighId, LowId).");
                }
            }

            return(Player);
        }