Exemple #1
0
        /// <summary>
        /// Saves the specified entity.
        /// </summary>
        /// <param name="Entity">The entity.</param>
        public static async Task Save(Clan Entity)
        {
            var Result = await ClanDb.Save(Entity);

            if (Result == null)
            {
                Logging.Error(typeof(Clans), "Result == null at Save(Entity).");
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates the specified entity.
        /// </summary>
        /// <param name="Entity">The entity.</param>
        /// <param name="Store">Whether it has to be stored.</param>
        public static async Task <Clan> Create(Clan Entity = null, bool Store = true)
        {
            if (Entity == null)
            {
                Entity = new Clan();
            }

            Entity.HighId = Clans.HighSeed;
            Entity.LowId  = Interlocked.Increment(ref Clans.LowSeed);

            await ClanDb.Create(Entity);

            if (Store)
            {
                Clans.Add(Entity);
            }

            return(Entity);
        }
Exemple #3
0
        /// <summary>
        /// Gets the entity using the specified identifiers.
        /// </summary>
        /// <param name="HighId">The high identifier.</param>
        /// <param name="LowId">The low identifier.</param>
        /// <param name="Store">Whether it has to be stored.</param>
        public static async Task <Clan> Get(int HighId, int LowId, bool Store = true)
        {
            Logging.Warning(typeof(Clans), "Get(" + HighId + ", " + LowId + ") has been called.");

            long ClanId = (long)HighId << 32 | (uint)LowId;

            ClanDb ClanDb = await ClanDb.Load(HighId, LowId);

            Clan Clan = null;

            if (Clans.Entities.TryGetValue(ClanId, out Clan))
            {
                return(Clan);
            }
            else
            {
                if (ClanDb != null)
                {
                    if (ClanDb.Deserialize(out Clan))
                    {
                        Clan.LoadingFinished();

                        if (Store)
                        {
                            Clans.Add(Clan);
                        }

                        return(Clan);
                    }
                    else
                    {
                        Logging.Error(typeof(Clans), "ClanDb.Deserialize(out Clan) != true at Get(" + HighId + ", " + LowId + ").");
                    }
                }
                else
                {
                    Logging.Warning(typeof(Clans), "ClanDb == null at Get(HighId, LowId).");
                }
            }

            return(Clan);
        }