public static void SetProperty(this Biota biota, PropertyString property, string value, ReaderWriterLockSlim rwLock) { rwLock.EnterUpgradeableReadLock(); try { var result = biota.BiotaPropertiesString.FirstOrDefault(x => x.Type == (uint)property); if (result != null) { result.Value = value; } else { rwLock.EnterWriteLock(); try { var entity = new BiotaPropertiesString { ObjectId = biota.Id, Type = (ushort)property, Value = value, Object = biota }; biota.BiotaPropertiesString.Add(entity); } finally { rwLock.ExitWriteLock(); } } } finally { rwLock.ExitUpgradeableReadLock(); } }
public static void SetProperty(this Biota biota, PropertyString property, string value) { var result = biota.BiotaPropertiesString.FirstOrDefault(x => x.Type == (uint)property); if (result != null) result.Value = value; else { var entity = new BiotaPropertiesString { ObjectId = biota.Id, Type = (ushort)property, Value = value, Object = biota }; biota.BiotaPropertiesString.Add(entity); } }
public static bool TryRemoveProperty(this Biota biota, PropertyString property, out BiotaPropertiesString entity, ReaderWriterLockSlim rwLock) { rwLock.EnterUpgradeableReadLock(); try { entity = biota.BiotaPropertiesString.FirstOrDefault(x => x.Type == (uint)property); if (entity != null) { rwLock.EnterWriteLock(); try { biota.BiotaPropertiesString.Remove(entity); entity.Object = null; return(true); } finally { rwLock.ExitWriteLock(); } } return(false); } finally { rwLock.ExitUpgradeableReadLock(); } }
public static bool TryRemoveProperty(this Biota biota, PropertyString property, out BiotaPropertiesString entity) { entity = biota.BiotaPropertiesString.FirstOrDefault(x => x.Type == (uint)property); if (entity != null) { biota.BiotaPropertiesString.Remove(entity); entity.Object = null; return true; } return false; }