/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/MassTransit/Initializers/PropertyInitializers/CopyObjectPropertyInitializer.cs
33 строки
1 KB
Chris Patterson
Integration of all external packages into MassTransit, split out into Abstractions, Middleware, and the core MassTransit assembly.
22 янв 2022, 18:24
22 янв 2022, 18:24
b5b4f50
Код
Авторство
О чём код?
namespace MassTransit.Initializers.PropertyInitializers { using System; using System.Reflection; using System.Threading.Tasks; using Internals; public class CopyObjectPropertyInitializer<TMessage, TInput, TInputProperty> : IPropertyInitializer<TMessage, TInput> where TMessage : class where TInput : class { readonly IReadProperty<TInput, TInputProperty> _inputProperty; readonly IWriteProperty<TMessage, object> _messageProperty; public CopyObjectPropertyInitializer(PropertyInfo messagePropertyInfo, PropertyInfo inputPropertyInfo) { if (messagePropertyInfo == null) throw new ArgumentNullException(nameof(messagePropertyInfo)); _inputProperty = ReadPropertyCache<TInput>.GetProperty<TInputProperty>(inputPropertyInfo); _messageProperty = WritePropertyCache<TMessage>.GetProperty<object>(messagePropertyInfo); } public Task Apply(InitializeContext<TMessage, TInput> context) { _messageProperty.Set(context.Message, _inputProperty.Get(context.Input)); return Task.CompletedTask; } } }