Esempio n. 1
0
        /// <summary>
        /// Create instance
        /// </summary>
        /// <param name="command">The command</param>
        public TResult Create(TCommand command)
        {
            bool enabled = _logger.IsDebugEnabled;

            string commandName = string.Empty;
            string productName = string.Empty;

            if (enabled)
            {
                commandName = typeof(TCommand).Name;
                productName = typeof(TResult).Name;
            }

            if (enabled)
            {
                _logger.DebugFormat(
                    "Creating {0} from {1} \r\n{2}",
                    productName,
                    commandName,
                    _logger.Serialize(command));
            }

            var created = _factory.Create(command);

            if (enabled)
            {
                _logger.DebugFormat(
                    "Created {0} from {1} :\r\n{2}",
                    productName,
                    commandName,
                    _logger.Serialize(created));
            }

            return(created);
        }
        private async Task <TResult> HandleWithDebug(TQuery query, CancellationToken cancellationToken)
        {
            string queryName = typeof(TQuery).Name;

            _logger.DebugFormat(
                "Executing query {0} :\r\n{1}",
                queryName,
                _logger.Serialize(query));

            var commandResult = await _handler
                                .Handle(query, cancellationToken)
                                .ConfigureAwait(Await.Default);

            _logger.DebugFormat(
                "Executed query {0} :\r\n{1}",
                queryName,
                _logger.Serialize(commandResult));

            return(commandResult);
        }
Esempio n. 3
0
        private async Task <IUploadResult> UploadWithDebug(
            TCommand command,
            CancellationToken cancellationToken)
        {
            string commandName = typeof(TCommand).Name;

            _logger.DebugFormat(
                "Executing upload command {0} :\r\n{1}",
                commandName,
                _logger.Serialize(command));

            var commandResult = await _uploader
                                .Upload(command, cancellationToken)
                                .ConfigureAwait(Await.Default);

            _logger.DebugFormat(
                "Executed upload command {0} :\r\n{1}",
                commandName,
                _logger.Serialize(commandResult));

            return(commandResult);
        }
        private async Task <QueueIntegrationImportCommandResult> HandleWithDebug(
            QueueIntegrationImportCommand command,
            CancellationToken cancellationToken)
        {
            const string commandName = nameof(QueueIntegrationImportCommand);

            _logger.DebugFormat(
                "Executing command {0} :\r\n{1}",
                commandName,
                _logger.Serialize(command));

            var commandResult = await _handler
                                .Handle(command, cancellationToken)
                                .ConfigureAwait(Await.Default);

            _logger.DebugFormat(
                "Executed command {0} :\r\n{1}",
                commandName,
                _logger.Serialize(commandResult));

            return(commandResult);
        }
        /// <summary>
        /// Create instance
        /// </summary>
        public T Create()
        {
            var created = _factory.Create();

            if (_logger.IsDebugEnabled)
            {
                string productName = typeof(T).Name;

                _logger.DebugFormat(
                    "Created {0} :\r\n{1}",
                    productName,
                    _logger.Serialize(created));
            }

            return(created);
        }