Beispiel #1
0
        public IDataManagementCommand CreateSetCommand(IRealObjectEndPoint endPoint, DomainObject newRelatedObject, Action <DomainObject> oppositeObjectSetter)
        {
            ArgumentUtility.CheckNotNull("endPoint", endPoint);
            ArgumentUtility.CheckNotNull("oppositeObjectSetter", oppositeObjectSetter);

            var oppositeEndPointDefinition = endPoint.Definition.GetOppositeEndPointDefinition();

            var newRelatedObjectID = newRelatedObject.GetSafeID();

            if (endPoint.OppositeObjectID == newRelatedObjectID)
            {
                return(new ObjectEndPointSetSameCommand(endPoint, _transactionEventSink));
            }
            else if (oppositeEndPointDefinition.IsAnonymous)
            {
                return(new ObjectEndPointSetUnidirectionalCommand(endPoint, newRelatedObject, oppositeObjectSetter, _transactionEventSink));
            }
            else
            {
                var setCommand =
                    oppositeEndPointDefinition.Cardinality == CardinalityType.One
                ? (IDataManagementCommand)
                    new ObjectEndPointSetOneOneCommand(endPoint, newRelatedObject, oppositeObjectSetter, _transactionEventSink)
                : new ObjectEndPointSetOneManyCommand(endPoint, newRelatedObject, oppositeObjectSetter, _endPointProvider, _transactionEventSink);

                var oldRelatedEndPoint = GetOppositeEndPoint(endPoint, endPoint.OppositeObjectID);
                var newRelatedEndPoint = GetOppositeEndPoint(endPoint, newRelatedObjectID);
                return(new RealObjectEndPointRegistrationCommandDecorator(setCommand, endPoint, oldRelatedEndPoint, newRelatedEndPoint));
            }
        }
Beispiel #2
0
        public bool ContainsOriginalObjectID(ObjectID objectID)
        {
            ArgumentUtility.CheckNotNull("objectID", objectID);

            return(Equals(_originalOppositeObject.GetSafeID(), objectID));
        }
 private string GetDomainObjectString(DomainObject domainObject)
 {
     return(GetObjectIDString(domainObject.GetSafeID()));
 }
Beispiel #4
0
        protected IRelationEndPoint GetOppositeEndPoint(
            IRelationEndPoint originatingEndPoint,
            DomainObject oppositeObject,
            IRelationEndPointProvider endPointProvider)
        {
            var oppositeEndPointID = RelationEndPointID.CreateOpposite(originatingEndPoint.Definition, oppositeObject.GetSafeID());

            return(endPointProvider.GetRelationEndPointWithLazyLoad(oppositeEndPointID));
        }
Beispiel #5
0
 public static T GetEndPointWithOppositeDefinition <T> (this IRelationEndPoint endPoint, DomainObject oppositeObject) where T : IRelationEndPoint
 {
     return(endPoint.GetEndPointWithOppositeDefinition <T> (oppositeObject.GetSafeID()));
 }