示例#1
0
        /// <summary>
        /// Creates all commands needed to perform a bidirectional remove operation from this collection end point.
        /// </summary>
        /// <remarks>
        /// A remove operation of the form "customer.Orders.Remove (RemovedOrder)" needs two steps:
        /// <list type="bullet">
        ///   <item>RemovedOrder.Customer = null and</item>
        ///   <item>customer.Orders.Remove (removedOrder).</item>
        /// </list>
        /// </remarks>
        public override ExpandedCommand ExpandToAllRelatedObjects()
        {
            var removedEndPoint = GetOppositeEndPoint(ModifiedEndPoint, OldRelatedObject, _endPointProvider);

            return(new ExpandedCommand(
                       removedEndPoint.CreateRemoveCommand(ModifiedEndPoint.GetDomainObject()),
                       this));
        }
        /// <summary>
        /// Creates all commands needed to perform a self-replace operation within this collection end point.
        /// </summary>
        /// <remarks>
        /// A self-replace operation of the form "customer.Orders[index] = customer.Orders[index]" needs two steps:
        /// <list type="bullet">
        ///   <item>customer.Orders.Touch() and</item>
        ///   <item>customer.Orders[index].Touch().</item>
        /// </list>
        /// No change notifications are sent for this operation.
        /// </remarks>
        public override ExpandedCommand ExpandToAllRelatedObjects()
        {
            var endPointOfRelatedObject = ModifiedEndPoint.GetEndPointWithOppositeDefinition <IRealObjectEndPoint> (OldRelatedObject);

            return(new ExpandedCommand(
                       this,
                       new RelationEndPointTouchCommand(endPointOfRelatedObject)));
        }
        public override void Perform()
        {
            // After this operation, NewCollection will be associated with the end-point and ModifiedEndPoint.Collection will return NewCollection.
            // The previous ModifiedEndPoint.Collection will be a standalone copy of the end-point data.
            var oldDataStrategyOfNewCollection = CollectionEndPointCollectionManager.AssociateCollectionWithEndPoint(NewCollection);

            // Now, replace end-point's data with the data that was held by NewCollection before it was associated.
            ModifiedCollectionData.ReplaceContents(oldDataStrategyOfNewCollection);

            ModifiedEndPoint.Touch();
        }
        /// <summary>
        /// Creates all commands needed to perform a bidirectional set-same operation on this <see cref="ObjectEndPoint"/>. One of the steps is
        /// this command, the other steps are the opposite commands on the new/old related objects.
        /// </summary>
        /// <remarks>
        /// A same-set operation of the form "order.OrderTicket = order.OrderTicket" needs two steps:
        /// <list type="bullet">
        ///   <item>order.Touch() and</item>
        ///   <item>order.OrderTicket.Touch.</item>
        /// </list>
        /// No change notifications are sent for this operation.
        /// </remarks>
        public override ExpandedCommand ExpandToAllRelatedObjects()
        {
            var oppositeEndPointDefinition = ModifiedEndPoint.Definition.GetOppositeEndPointDefinition();

            if (oppositeEndPointDefinition.IsAnonymous)
            {
                return(new ExpandedCommand(this));
            }
            else
            {
                var oppositeEndPoint = ModifiedEndPoint.GetEndPointWithOppositeDefinition <IRelationEndPoint> (NewRelatedObject);
                return(new ExpandedCommand(this, new RelationEndPointTouchCommand(oppositeEndPoint)));
            }
        }
        /// <summary>
        /// Creates all commands needed to perform a bidirectional 1:n set operation on this <see cref="ObjectEndPoint"/>. One of the steps is
        /// this command, the other steps are the opposite commands on the new/old related objects.
        /// </summary>
        /// <remarks>
        /// A 1:n set operation of the form "order.Customer = newCustomer" needs three steps:
        /// <list type="bullet">
        ///   <item>order.Customer = newCustomer,</item>
        ///   <item>newCustomer.Orders.Add (order), and</item>
        ///   <item>oldCustomer.Orders.Remove (order).</item>
        /// </list>
        /// </remarks>
        public override ExpandedCommand ExpandToAllRelatedObjects()
        {
            var newRelatedEndPoint = (ICollectionEndPoint)GetOppositeEndPoint(ModifiedEndPoint, NewRelatedObject, _endPointProvider);
            var oldRelatedEndPoint = (ICollectionEndPoint)GetOppositeEndPoint(ModifiedEndPoint, OldRelatedObject, _endPointProvider);

            var bidirectionalModification = new ExpandedCommand(
                // => order.Customer = newCustomer
                this,
                // => newCustomer.Orders.Add (order)
                newRelatedEndPoint.CreateAddCommand(ModifiedEndPoint.GetDomainObject()),
                // => oldCustomer.Orders.Remove (order) (remove)
                oldRelatedEndPoint.CreateRemoveCommand(ModifiedEndPoint.GetDomainObject()));

            return(bidirectionalModification);
        }
示例#6
0
        /// <summary>
        /// Creates all commands needed to perform a bidirectional insert operation into this collection end point.
        /// </summary>
        /// <remarks>
        /// An insert operation of the form "customer.Orders.Insert (insertedOrder, index)" needs three steps:
        /// <list type="bullet">
        ///   <item>insertedOrder.Customer = customer,</item>
        ///   <item>customer.Orders.Insert (insertedOrder, index), and</item>
        ///   <item>oldCustomer.Orders.Remove (insertedOrder) - with oldCustomer being the old customer of the inserted order (if non-null).</item>
        /// </list>
        /// </remarks>
        public override ExpandedCommand ExpandToAllRelatedObjects()
        {
            // the end point that will be linked to the collection end point after the operation
            var insertedObjectEndPoint = (IRealObjectEndPoint)GetOppositeEndPoint(ModifiedEndPoint, NewRelatedObject, _endPointProvider);
            // the object that was linked to the new related object before the operation
            var oldRelatedObjectOfInsertedObject = insertedObjectEndPoint.GetOppositeObject();
            // the end point that was linked to the new related object before the operation
            var oldRelatedEndPointOfInsertedObject = GetOppositeEndPoint(insertedObjectEndPoint, oldRelatedObjectOfInsertedObject, _endPointProvider);

            return(new ExpandedCommand(
                       // insertedOrder.Customer = customer (previously oldCustomer)
                       insertedObjectEndPoint.CreateSetCommand(ModifiedEndPoint.GetDomainObject()),
                       // customer.Orders.Insert (insertedOrder, index)
                       this,
                       // oldCustomer.Orders.Remove (insertedOrder)
                       oldRelatedEndPointOfInsertedObject.CreateRemoveCommand(NewRelatedObject)));
        }
        /// <summary>
        /// Creates all commands needed to perform a bidirectional collection replace operation within this collection end point.
        /// </summary>
        /// <remarks>
        /// A replace operation of the form "customer.Orders = newOrders" involves the following steps:
        /// <list type="bullet">
        ///   <item>for each oldOrder the old collection (Orders) that's not in the new one: oldOrder.Customer = <see langword="null" />,</item>
        ///   <item>for each newOrder in the new collection (newOrders) that's not in the old one: newOrder.Customer.Orders.Remove (newOrder),</item>
        ///   <item>for each newOrder in the new collection (newOrders) that's not in the old one: newOrder.Customer = customer,</item>
        ///   <item>customer.Orders = newOrders.</item>
        /// </list>
        /// </remarks>
        public override ExpandedCommand ExpandToAllRelatedObjects()
        {
            var domainObjectOfCollectionEndPoint = base.ModifiedEndPoint.GetDomainObject();

            var commandsForRemoved = from oldObject in RemovedObjects
                                     let endPoint = ModifiedEndPoint.GetEndPointWithOppositeDefinition <IRealObjectEndPoint> (oldObject)
                                                    select endPoint.CreateRemoveCommand(domainObjectOfCollectionEndPoint); // oldOrder.Customer = null

            var commandsForAdded = from newObject in AddedObjects
                                   let endPointOfNewObject = ModifiedEndPoint.GetEndPointWithOppositeDefinition <IRealObjectEndPoint> (newObject)                                                                                          // newOrder.Customer
                                                             let oldRelatedOfNewObject = endPointOfNewObject.GetOppositeObject()                                                                                                           // newOrder.Customer
                                                                                         let endPointOfOldRelatedOfNewObject = endPointOfNewObject.GetEndPointWithOppositeDefinition <ICollectionEndPoint> (oldRelatedOfNewObject)         // newOrder.Customer.Orders
                                                                                                                               let removeCommand = endPointOfOldRelatedOfNewObject.CreateRemoveCommand(newObject)                          // newOrder.Customer.Orders.Remove (newOrder)
                                                                                                                                                   let setCommand = endPointOfNewObject.CreateSetCommand(domainObjectOfCollectionEndPoint) // newOrder.Customer = customer
                                                                                                                                                                    from command in new[] { removeCommand, setCommand }
            select command;

            return(new ExpandedCommand(commandsForRemoved).CombineWith(commandsForAdded).CombineWith(this));
        }
        /// <summary>
        /// Creates all commands needed to perform a bidirectional replace operation within this collection end point.
        /// </summary>
        /// <remarks>
        /// A replace operation of the form "customer.Orders[index] = newOrder" needs four steps:
        /// <list type="bullet">
        ///   <item>customer.Order[index].Customer = null,</item>
        ///   <item>newOrder.Customer = customer,</item>
        ///   <item>customer.Orders[index] = newOrder,</item>
        ///   <item>oldCustomer.Orders.Remove (insertedOrder) - with oldCustomer being the old customer of the new order (if non-null).</item>
        /// </list>
        /// </remarks>
        public override ExpandedCommand ExpandToAllRelatedObjects()
        {
            // the end point that will be linked to the collection end point after the operation
            var endPointOfNewObject = ModifiedEndPoint.GetEndPointWithOppositeDefinition <IRealObjectEndPoint> (NewRelatedObject);
            // the end point that was linked to the collection end point before the operation
            var endPointOfOldObject = ModifiedEndPoint.GetEndPointWithOppositeDefinition <IRealObjectEndPoint> (OldRelatedObject);
            // the object that was linked to the new related object before the operation
            var oldRelatedObjectOfNewObject = endPointOfNewObject.GetOppositeObject();
            // the end point that was linked to the new related object before the operation
            var oldRelatedEndPointOfNewObject = endPointOfNewObject.GetEndPointWithOppositeDefinition <ICollectionEndPoint> (oldRelatedObjectOfNewObject);

            return(new ExpandedCommand(
                       // customer.Order[index].Customer = null
                       endPointOfOldObject.CreateRemoveCommand(ModifiedEndPoint.GetDomainObject()),
                       // newOrder.Customer = customer
                       endPointOfNewObject.CreateSetCommand(ModifiedEndPoint.GetDomainObject()),
                       // customer.Orders[index] = newOrder
                       this,
                       // oldCustomer.Orders.Remove (insertedOrder)
                       oldRelatedEndPointOfNewObject.CreateRemoveCommand(NewRelatedObject)));
        }
 public override void Perform()
 {
     _oppositeObjectNullSetter();
     ModifiedEndPoint.Touch();
 }
 public override void Perform()
 {
     ModifiedCollectionData.Replace(_index, NewRelatedObject);
     ModifiedEndPoint.Touch();
 }
 public override void Perform()
 {
     ModifiedEndPoint.Touch();
 }
示例#12
0
 public override void Perform()
 {
     ModifiedCollectionData.Remove(OldRelatedObject);
     ModifiedEndPoint.Touch();
 }
示例#13
0
 public override void Perform()
 {
     ModifiedCollectionData.Clear();
     ModifiedEndPoint.Touch();
 }
示例#14
0
 public override void Perform()
 {
     _oppositeObjectSetter(NewRelatedObject);
     ModifiedEndPoint.Touch();
 }