protected virtual void UnregisterOppositeForRealObjectEndPoint(IRealObjectEndPoint realObjectEndPoint, RelationEndPointMap map) { ArgumentUtility.CheckNotNull("realObjectEndPoint", realObjectEndPoint); ArgumentUtility.CheckNotNull("map", map); var oppositeEndPointID = RelationEndPointID.CreateOpposite(realObjectEndPoint.Definition, realObjectEndPoint.OriginalOppositeObjectID); if (oppositeEndPointID.Definition.IsAnonymous) { realObjectEndPoint.ResetSyncState(); return; } var oppositeEndPoint = _virtualEndPointProvider.GetOrCreateVirtualEndPoint(oppositeEndPointID); if (oppositeEndPoint == null) { var message = string.Format( "Opposite end-point of '{0}' not found. When unregistering a non-virtual bidirectional end-point, the opposite end-point must exist.", realObjectEndPoint.ID); throw new InvalidOperationException(message); } oppositeEndPoint.UnregisterOriginalOppositeEndPoint(realObjectEndPoint); if (oppositeEndPoint.CanBeCollected) { map.RemoveEndPoint(oppositeEndPoint.ID); } }
public void Reset() { foreach (var endPoint in _map.Select(endPoint => endPoint).ToList()) { endPoint.Rollback(); _map.RemoveEndPoint(endPoint.ID); } }
public void UnregisterEndPoint(IRelationEndPoint endPoint, RelationEndPointMap map) { ArgumentUtility.CheckNotNull("endPoint", endPoint); ArgumentUtility.CheckNotNull("map", map); if (map[endPoint.ID] != endPoint) { var message = string.Format("End-point '{0}' is not part of this map.\r\nParameter name: endPoint", endPoint.ID); throw new ArgumentException(message); } var realObjectEndPoint = endPoint as IRealObjectEndPoint; if (realObjectEndPoint != null) { UnregisterOppositeForRealObjectEndPoint(realObjectEndPoint, map); } map.RemoveEndPoint(endPoint.ID); }