コード例 #1
0
        /// <summary>
        /// Finishes the transport by committing the <see cref="DataTransaction"/> to the database, providing a filter to exclude some objects
        /// from being committed.
        /// </summary>
        /// <param name="filter">A filter delegate called for each object that would be committed to the database. Return true to include the
        /// object in the commit, or false to leave its state in the database as is.</param>
        /// <remarks>This method invalidated the <see cref="TransportedDomainObjects"/> object, setting <see cref="DataTransaction"/> and
        /// <see cref="TransportedObjects"/> to <see langword="null"/> and discarding <see cref="DataTransaction"/>. The transported object references
        /// cannot be used any longer after calling this method.</remarks>
        public void FinishTransport(Func <DomainObject, bool> filter)
        {
            ArgumentUtility.CheckNotNull("filter", filter);

            if (DataTransaction == null)
            {
                throw new InvalidOperationException("FinishTransport can only be called once.");
            }

            DataTransaction.AddListener(new TransportFinishTransactionListener(filter));
            DataTransaction.Commit();
            DataTransaction.Discard();

            _dataTransaction    = null;
            _transportedObjects = null;
        }