Ejemplo n.º 1
0
        // =====================================
        // BiotaPropertiesSkill
        // =====================================

        public static BiotaPropertiesSkill GetOrAddSkill(this Biota biota, ushort type, ReaderWriterLockSlim rwLock, out bool skillAdded)
        {
            rwLock.EnterUpgradeableReadLock();
            try
            {
                var entity = biota.BiotaPropertiesSkill.FirstOrDefault(x => x.Type == type);
                if (entity != null)
                {
                    skillAdded = false;
                    return(entity);
                }

                rwLock.EnterWriteLock();
                try
                {
                    entity = new BiotaPropertiesSkill {
                        ObjectId = biota.Id, Type = type, Object = biota
                    };
                    biota.BiotaPropertiesSkill.Add(entity);
                    skillAdded = true;
                    return(entity);
                }
                finally
                {
                    rwLock.ExitWriteLock();
                }
            }
            finally
            {
                rwLock.ExitUpgradeableReadLock();
            }
        }
Ejemplo n.º 2
0
        public static BiotaPropertiesSkill GetOrAddSkill(this Biota biota, ushort type, out bool skillAdded)
        {
            var entity = biota.BiotaPropertiesSkill.FirstOrDefault(x => x.Type == type);

            if (entity != null)
            {
                skillAdded = false;
                return entity;
            }

            entity = new BiotaPropertiesSkill { ObjectId = biota.Id, Type = type, Object = biota };

            biota.BiotaPropertiesSkill.Add(entity);
            skillAdded = true;
            return entity;
        }