Example #1
0
        public Task Apply(InitializeContext <TMessage, TInput> context)
        {
            Task <TProperty> propertyTask = _propertyProvider.GetProperty(context);

            if (propertyTask.IsCompleted)
            {
                if (_messageProperty.TargetType == context.MessageType)
                {
                    _messageProperty.Set(context.Message, propertyTask.Result);
                }
                return(TaskUtil.Completed);
            }

            async Task ApplyAsync()
            {
                var propertyValue = await propertyTask.ConfigureAwait(false);

                if (_messageProperty.TargetType == context.MessageType)
                {
                    _messageProperty.Set(context.Message, propertyValue);
                }
            }

            return(ApplyAsync());
        }
        public Task Apply(InitializeContext <TMessage, TInput> context, SendContext sendContext)
        {
            var propertyTask = _propertyProvider.GetProperty(context);

            if (propertyTask.IsCompleted)
            {
                _messageProperty.Set(sendContext, propertyTask.Result);
                return(TaskUtil.Completed);
            }

            return(ApplyAsync(sendContext, propertyTask));
        }
        public Task Apply(InitializeContext <TMessage, TInput> context, SendContext sendContext)
        {
            var inputPropertyValue = _inputProperty.Get(context.Input);

            _headerProperty.Set(sendContext, inputPropertyValue);

            return(TaskUtil.Completed);
        }
Example #4
0
        public Task Apply(InitializeContext <TMessage, TInput> context)
        {
            if (context.HasInput)
            {
                _messageProperty.Set(context.Message, _inputProperty.Get(context.Input));
            }

            return(TaskUtil.Completed);
        }
        public Task Apply(InitializeContext <TMessage, TInput> context, SendContext sendContext)
        {
            if (context.HasInput && context.Input.TryGetValue(_key, out var value))
            {
                _headerProperty.Set(sendContext, value);
            }

            return(TaskUtil.Completed);
        }
Example #6
0
        public void ToEntity(TEntity entity, IDictionary <string, EntityProperty> entityProperties)
        {
            if (entityProperties.TryGetValue(_name, out var entityProperty))
            {
                if (_toEntity != null)
                {
                    if (_toEntity.TryConvert(entityProperty, out var propertyValue))
                    {
                        _write.Set(entity, propertyValue);
                    }
                }
                else
                {
                    var propertyValue = JsonConvert.DeserializeObject <TProperty>(entityProperty.StringValue);

                    _write.Set(entity, propertyValue);
                }
            }
        }
        public async Task Apply(InitializeContext <TMessage, TInput> context)
        {
            if (context.HasInput)
            {
                var inputProperty = _inputProperty.Get(context.Input);

                var messageProperty = await _converter.Convert(context, inputProperty).ConfigureAwait(false);

                _messageProperty.Set(context.Message, messageProperty);
            }
        }
Example #8
0
        public Task Apply(InitializeMessageContext <TMessage, TInput> context)
        {
            var inputProperty = _inputProperty.Get(context.Input);

            if (_converter.TryConvert(inputProperty, out var messageProperty))
            {
                _messageProperty.Set(context.Message, messageProperty);
                return(TaskUtil.Completed);
            }

            throw new MassTransitException($"The input property {_inputProperty.Name} could not be converted to the message property {_messageProperty.Name}.");
        }
        public async Task Apply(InitializeContext <TMessage, TInput> context)
        {
            var propertyValue = await _propertyProvider.GetProperty(context).ConfigureAwait(false);

            _messageProperty.Set(context.Message, propertyValue);
        }