Ejemplo n.º 1
0
        // the separate services implementation is more flexible because each of the separate objects
        // can have their own decorator(s)...
        static OrderController CreateSeparateServices()
        {
            var reader            = new OrderReader();
            var readCachingReader = new ReadCaching <Order>(reader);

            var saver          = new OrderSaver();
            var auditInfoSaver = new AuditInfoSaver();
            var auditingSaver  = new SaveAuditing <Order>(saver, auditInfoSaver);

            var deleter               = new OrderDeleter();
            var deleteConfirmation    = new DeleteConfirmation <Order>(deleter);
            var eventPublisher        = new EventPublisher <Order>();
            var deleteEventPublishing = new DeleteEventPublishing <Order>(deleteConfirmation, eventPublisher);

            var genericController = new GenericController <Order>(readCachingReader, auditingSaver, deleteEventPublishing);
            var orderController   = new OrderController(reader, saver, deleter);

            return(orderController);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a CRUD instance that is fully decorated. Note that the various Order objects
        /// are not fully implemented in this example. In complete implementations, these concrete
        /// instances would interact with a data store for the various CRUD operations.
        /// </summary>
        /// <returns></returns>
        static ICreateReadUpdateDelete <Order> CreateOrderController()
        {
            var reader            = new OrderReader();
            var readCachingReader = new ReadCaching <Order>(reader);

            var saver          = new OrderSaver();
            var auditInfoSaver = new AuditInfoSaver();
            var auditingSaver  = new SaveAuditing <Order>(saver, auditInfoSaver);

            var deleter               = new OrderDeleter();
            var deleteConfirmation    = new DeleteConfirmation <Order>(deleter);
            var eventPublisher        = new EventPublisher <Order>();
            var deleteEventPublishing = new DeleteEventPublishing <Order>(deleteConfirmation, eventPublisher);

            var orderController = new GenericController <Order>(readCachingReader, auditingSaver, deleteEventPublishing);
            var transactionalOrderController = new CrudTransactional <Order>(orderController);

            var logger = new Logger();
            var orderControllerWithLogging = new CrudLogging <Order>(transactionalOrderController, logger);

            return(orderControllerWithLogging);
        }