Ejemplo n.º 1
0
        void ApplyOperation(
            UnitOfWorkAction action, IList <IDomainObject> affectedEntities,
            SuccessfulUoWInvocationDelegate successfulInvocation, FailedUoWInvocationDelegate failedInvocation
            )
        {
            for (int index = 0; index < affectedEntities.Count; index++)
            {
                IDomainObject entity = affectedEntities[index];

                if (entity == null)
                {
                    continue;
                }

                IBaseMapper       mapper    = entity.Mapper;
                OperationDelegate operation = GetOperation(action, mapper);

                bool success = operation(ref entity,
                                         (domainObject, results) =>
                {
                    if (successfulInvocation != null)
                    {
                        successfulInvocation(domainObject, action, results);
                    }
                },
                                         (domainObject, results) =>
                {
                    if (failedInvocation != null)
                    {
                        failedInvocation(domainObject, action, results);
                    }
                });
            }
        }
Ejemplo n.º 2
0
        OperationDelegate GetOperation(UnitOfWorkAction action, IBaseMapper mapper)
        {
            OperationDelegate operation = null;

            switch (action)
            {
            case UnitOfWorkAction.Insert:
                operation = new OperationDelegate(mapper.Insert);
                break;

            case UnitOfWorkAction.Update:
                operation = new OperationDelegate(mapper.Update);
                break;

            case UnitOfWorkAction.Delete:
                operation = new OperationDelegate(mapper.Delete);
                break;
            }

            return(operation);
        }