コード例 #1
0
        /// <summary>
        /// Resurrects the invalid <see cref="DomainObject"/> with the given <paramref name="objectID"/> in the hierarchy of the given
        /// <paramref name="clientTransaction"/>, throwing an exception if resurrection is not possible.
        /// </summary>
        /// <param name="clientTransaction">A <see cref="ClientTransaction"/> identifying the hierarchy in which to resurrect the object. The object
        /// is resurrected in all transactions of the hierarchy.</param>
        /// <param name="objectID">The <see cref="ObjectID"/> of the object to resurrect.</param>
        /// <exception cref="InvalidOperationException">The <see cref="DomainObject"/> identified by <paramref name="objectID"/> is not invalid in at
        /// least one <see cref="ClientTransaction"/> of the transaction hierarchy identified by <paramref name="clientTransaction"/>.</exception>
        public static void ResurrectInvalidObject(ClientTransaction clientTransaction, ObjectID objectID)
        {
            ArgumentUtility.CheckNotNull("clientTransaction", clientTransaction);
            ArgumentUtility.CheckNotNull("objectID", objectID);

            var executor = new TransactionHierarchyCommandExecutor(tx => CreateMarkNotInvalidCommand(tx, objectID));

            executor.ExecuteCommandForTransactionHierarchy(clientTransaction);
        }
コード例 #2
0
        /// <summary>
        /// Unloads all the data and relation end-points from the <see cref="ClientTransaction"/> hierarchy indicated by the given
        /// <paramref name="clientTransaction"/>. This operation always succeeds (unless it is canceled by an exception thrown from a
        /// <see cref="IClientTransactionListener.ObjectsUnloading"/> or <see cref="DomainObject.OnUnloading"/> notification method).
        /// </summary>
        /// <param name="clientTransaction">The <see cref="ClientTransaction"/> to unload the data from. The unload operation always affects the whole transaction
        /// hierarchy.</param>
        /// <exception cref="ArgumentNullException">One of the arguments passed to this method is <see langword="null"/>.</exception>
        /// <remarks>
        /// <para>
        /// The unload operation is atomic over the transaction hierarchy. If the operation is canceled in any of the transactions,
        /// it will not unload any data.
        /// </para>
        /// <para>
        /// The effect of this operation is similar to that of a <see cref="ClientTransaction.Rollback"/> followed by calling
        /// <see cref="UnloadVirtualEndPoint"/> and <see cref="UnloadData"/> for every piece of data in the <see cref="ClientTransaction"/>, although
        /// the operation won't raise any Rollback-related events.
        /// </para>
        /// <para>
        /// When the operation completes, the state of previously <see cref="StateType.Changed"/>, <see cref="StateType.Deleted"/>, and
        /// <see cref="StateType.Unchanged"/> objects becomes <see cref="StateType.NotLoadedYet"/>. The state of <see cref="StateType.New"/> objects
        /// becomes <see cref="StateType.Invalid"/> (this state is propagated over within the whole transaction hierarchy).
        /// The state of <see cref="StateType.Invalid"/> and <see cref="StateType.NotLoadedYet"/> objects stays the same.
        /// </para>
        /// <para>
        /// When the operation completes, all virtual relation end-points will no longer be complete, and they will be reloaded on access. All changes,
        /// including <see cref="DomainObjectCollection"/> references set into relation properties, will be rolled back.
        /// </para>
        /// </remarks>
        public static void UnloadAll(ClientTransaction clientTransaction)
        {
            ArgumentUtility.CheckNotNull("clientTransaction", clientTransaction);

            Func <ClientTransaction, IDataManagementCommand> commandFactory = tx => tx.DataManager.CreateUnloadAllCommand();
            var executor = new TransactionHierarchyCommandExecutor(commandFactory);

            executor.ExecuteCommandForTransactionHierarchy(clientTransaction);
        }
コード例 #3
0
        /// <summary>
        /// Unloads the virtual relation end point indicated by the given <see cref="RelationEndPointID"/> in the specified
        /// <see cref="ClientTransaction"/>. If the end point has not been loaded or has already been unloaded, this method does nothing.
        /// The relation must be unchanged in order to be unloaded, and it must not belong to an object that is new or deleted.
        /// </summary>
        /// <param name="clientTransaction">The <see cref="ClientTransaction"/> to unload the data from. The unload operation always affects the whole transaction
        /// hierarchy.</param>
        /// <param name="endPointID">The ID of the relation property to unload. This must denote a virtual relation end-point, ie., the relation side not
        /// holding the foreign key property.</param>
        /// <exception cref="InvalidOperationException">The given end point is not in unchanged state.</exception>
        /// <exception cref="ArgumentNullException">One of the arguments passed to this method is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentException">The given <paramref name="endPointID"/> does not specify a virtual relation end point.</exception>
        /// <remarks>
        /// <para>
        /// The unload operation is atomic over the transaction hierarchy. If the operation cannot be performed or is canceled in any of the transactions,
        /// it will stop before any data is unloaded.
        /// </para>
        /// </remarks>
        public static void UnloadVirtualEndPoint(ClientTransaction clientTransaction, RelationEndPointID endPointID)
        {
            ArgumentUtility.CheckNotNull("clientTransaction", clientTransaction);
            ArgumentUtility.CheckNotNull("endPointID", endPointID);

            CheckVirtualEndPointID(endPointID);

            Func <ClientTransaction, IDataManagementCommand> commandFactory = tx => tx.DataManager.CreateUnloadVirtualEndPointsCommand(endPointID);
            var executor = new TransactionHierarchyCommandExecutor(commandFactory);

            executor.ExecuteCommandForTransactionHierarchy(clientTransaction);
        }
コード例 #4
0
        public void ExecuteCommandForTransactionHierarchy_LeafRootTransaction()
        {
            _commandFactoryMock
            .Expect(mock => mock.Create(_leafRootTransaction))
            .Return(_commandMock1);
            _commandMock1.Stub(stub => stub.GetAllExceptions()).Return(new Exception[0]);

            using (_mockRepository.Ordered())
            {
                _commandMock1.Expect(mock => mock.Begin());
                _commandMock1.Expect(mock => mock.Perform());
                _commandMock1.Expect(mock => mock.End());
            }

            _mockRepository.ReplayAll();

            _executor.ExecuteCommandForTransactionHierarchy(_leafRootTransaction);

            _mockRepository.VerifyAll();
        }