/// <summary> /// Releases the entity. An owner can only release an entity /// if it retains it. /// Retain/Release is part of AERC (Automatic Entity Reference Counting) /// and is used internally to prevent pooling retained entities. /// If you use retain manually you also have to /// release it manually at some point. /// </summary> /// <param name="owner"></param> public void Release(object owner) { _aerc.Release(owner); // TODO VD PERFORMANCE // _toStringCache = null; if (_aerc.RetainCount == 0) { OnEntityReleased?.Invoke(this); } }
public void Release(object owner) { if (!owners.Remove(owner)) { throw new EntityIsNotRetainedByOwnerException <T>(this, owner); } if (owners.Count == 0) { _toStringCache = null; OnEntityReleased?.Invoke(this); } }