public void Discard(DataContainer dataContainer) { ArgumentUtility.CheckNotNull("dataContainer", dataContainer); var unregisterEndPointsCommand = _relationEndPointManager.CreateUnregisterCommandForDataContainer(dataContainer); var unregisterDataContainerCommand = CreateUnregisterDataContainerCommand(dataContainer.ID); var compositeCommand = new CompositeCommand(unregisterEndPointsCommand, unregisterDataContainerCommand); try { compositeCommand.NotifyAndPerform(); } catch (Exception ex) { var message = string.Format("Cannot discard data for object '{0}': {1}", dataContainer.ID, ex.Message); throw new InvalidOperationException(message, ex); } dataContainer.Discard(); var domainObject = dataContainer.DomainObject; _invalidDomainObjectManager.MarkInvalid(domainObject); }
public void Perform() { // Reset end-point manager before resetting the DataContainers so that the VirtualEndPointUnregistering events come before the // DataManagerUnregistering events (although that shouldn't make any difference to users and is definitely an implementation detail) _relationEndPointManager.Reset(); _unloadedDataContainers = _dataContainerMap.ToList(); foreach (var dataContainer in _unloadedDataContainers) { _dataContainerMap.Remove(dataContainer.ID); var dataContainerState = dataContainer.State; dataContainer.Discard(); if (dataContainerState == StateType.New) { _invalidDomainObjectManager.MarkInvalid(dataContainer.DomainObject); } } Assertion.IsTrue(_dataContainerMap.Count == 0); }