public ObjectEndPointSetSameCommand(IObjectEndPoint modifiedEndPoint, IClientTransactionEventSink transactionEventSink)
     : base(
         ArgumentUtility.CheckNotNull("modifiedEndPoint", modifiedEndPoint),
         modifiedEndPoint.GetOppositeObject(),
         modifiedEndPoint.GetOppositeObject(),
         transactionEventSink)
 {
 }
Beispiel #2
0
        protected ObjectEndPointSetCommand(
            IObjectEndPoint modifiedEndPoint,
            DomainObject newRelatedObject,
            Action <DomainObject> oppositeObjectSetter,
            IClientTransactionEventSink transactionEventSink
            )
            : base(ArgumentUtility.CheckNotNull("modifiedEndPoint", modifiedEndPoint),
                   modifiedEndPoint.GetOppositeObject(),
                   newRelatedObject,
                   ArgumentUtility.CheckNotNull("transactionEventSink", transactionEventSink))
        {
            ArgumentUtility.CheckNotNull("oppositeObjectSetter", oppositeObjectSetter);

            if (modifiedEndPoint.IsNull)
            {
                throw new ArgumentException("Modified end point is null, a NullEndPointModificationCommand is needed.", "modifiedEndPoint");
            }

            _oppositeObjectSetter = oppositeObjectSetter;
        }
        public ObjectEndPointSetUnidirectionalCommand(
            IObjectEndPoint modifiedEndPoint,
            DomainObject newRelatedObject,
            Action <DomainObject> oppositeObjectSetter,
            IClientTransactionEventSink transactionEventSink)
            : base(modifiedEndPoint, newRelatedObject, oppositeObjectSetter, transactionEventSink)
        {
            if (!modifiedEndPoint.Definition.GetOppositeEndPointDefinition().IsAnonymous)
            {
                var message = string.Format("EndPoint '{0}' is from a bidirectional relation - use a ObjectEndPointSetOneOneCommand or ObjectEndPointSetOneManyCommand instead.",
                                            modifiedEndPoint.Definition.PropertyName);
                throw new ArgumentException(message, "modifiedEndPoint");
            }

            if (newRelatedObject == modifiedEndPoint.GetOppositeObject())
            {
                var message = string.Format("New related object for EndPoint '{0}' is the same as its old value - use a ObjectEndPointSetSameCommand instead.",
                                            modifiedEndPoint.Definition.PropertyName);
                throw new ArgumentException(message, "newRelatedObject");
            }
        }