コード例 #1
0
ファイル: BiotaExtensions.cs プロジェクト: zarlant/ACE
 public static bool TryRemoveProperty(this Biota biota, PropertyInt property, out BiotaPropertiesInt entity, ReaderWriterLockSlim rwLock)
 {
     rwLock.EnterUpgradeableReadLock();
     try
     {
         entity = biota.BiotaPropertiesInt.FirstOrDefault(x => x.Type == (uint)property);
         if (entity != null)
         {
             rwLock.EnterWriteLock();
             try
             {
                 biota.BiotaPropertiesInt.Remove(entity);
                 entity.Object = null;
                 return(true);
             }
             finally
             {
                 rwLock.ExitWriteLock();
             }
         }
         return(false);
     }
     finally
     {
         rwLock.ExitUpgradeableReadLock();
     }
 }
コード例 #2
0
ファイル: BiotaExtensions.cs プロジェクト: zarlant/ACE
 public static void SetProperty(this Biota biota, PropertyInt property, int value, ReaderWriterLockSlim rwLock)
 {
     rwLock.EnterUpgradeableReadLock();
     try
     {
         var result = biota.BiotaPropertiesInt.FirstOrDefault(x => x.Type == (uint)property);
         if (result != null)
         {
             result.Value = value;
         }
         else
         {
             rwLock.EnterWriteLock();
             try
             {
                 var entity = new BiotaPropertiesInt {
                     ObjectId = biota.Id, Type = (ushort)property, Value = value, Object = biota
                 };
                 biota.BiotaPropertiesInt.Add(entity);
             }
             finally
             {
                 rwLock.ExitWriteLock();
             }
         }
     }
     finally
     {
         rwLock.ExitUpgradeableReadLock();
     }
 }
コード例 #3
0
ファイル: BiotaExtensions.cs プロジェクト: PyrealMote/ACE
 public static bool TryRemoveProperty(this Biota biota, PropertyInt property, out BiotaPropertiesInt entity)
 {
     entity = biota.BiotaPropertiesInt.FirstOrDefault(x => x.Type == (uint)property);
     if (entity != null)
     {
         biota.BiotaPropertiesInt.Remove(entity);
         entity.Object = null;
         return(true);
     }
     return(false);
 }
コード例 #4
0
        public static void SetProperty(this Biota biota, PropertyInt property, int value)
        {
            var result = biota.BiotaPropertiesInt.FirstOrDefault(x => x.Type == (uint)property);

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

                biota.BiotaPropertiesInt.Add(entity);
            }
        }