Esempio n. 1
0
 public static void SetProperty(this Biota biota, PropertyBool property, bool value, ReaderWriterLockSlim rwLock)
 {
     rwLock.EnterUpgradeableReadLock();
     try
     {
         var result = biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);
         if (result != null)
         {
             result.Value = value;
         }
         else
         {
             rwLock.EnterWriteLock();
             try
             {
                 var entity = new BiotaPropertiesBool {
                     ObjectId = biota.Id, Type = (ushort)property, Value = value, Object = biota
                 };
                 biota.BiotaPropertiesBool.Add(entity);
             }
             finally
             {
                 rwLock.ExitWriteLock();
             }
         }
     }
     finally
     {
         rwLock.ExitUpgradeableReadLock();
     }
 }
Esempio n. 2
0
        // =====================================
        // Set
        // Bool, DID, Float, IID, Int, Int64, String, Position
        // =====================================

        public static void SetProperty(this Biota biota, PropertyBool property, bool value)
        {
            var result = biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);

            if (result != null)
                result.Value = value;
            else
            {
                var entity = new BiotaPropertiesBool { ObjectId = biota.Id, Type = (ushort)property, Value = value, Object = biota };

                biota.BiotaPropertiesBool.Add(entity);
            }
        }
Esempio n. 3
0
 public static bool TryRemoveProperty(this Biota biota, PropertyBool property, out BiotaPropertiesBool entity, ReaderWriterLockSlim rwLock)
 {
     rwLock.EnterUpgradeableReadLock();
     try
     {
         entity = biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);
         if (entity != null)
         {
             rwLock.EnterWriteLock();
             try
             {
                 biota.BiotaPropertiesBool.Remove(entity);
                 entity.Object = null;
                 return(true);
             }
             finally
             {
                 rwLock.ExitWriteLock();
             }
         }
         return(false);
     }
     finally
     {
         rwLock.ExitUpgradeableReadLock();
     }
 }
Esempio n. 4
0
        // =====================================
        // Remove
        // Bool, DID, Float, IID, Int, Int64, String, Position
        // =====================================

        public static bool TryRemoveProperty(this Biota biota, PropertyBool property, out BiotaPropertiesBool entity)
        {
            entity = biota.BiotaPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);

            if (entity != null)
            {
                biota.BiotaPropertiesBool.Remove(entity);
                entity.Object = null;
                return true;
            }

            return false;
        }