/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/MassTransit/Initializers/PropertyProviders/InputDictionaryPropertyProvider.cs
37 строк
1 KB
Chris Patterson
Message Initializer Task/async optimization, added initializer constructor check for implementation types, added test to verify Fault<T> covariance
10 окт 2019, 19:31
10 окт 2019, 19:31
7af8a3a
Код
Авторство
О чём код?
namespace MassTransit.Initializers.PropertyProviders { using System; using System.Collections.Generic; using System.Threading.Tasks; using Util; /// <summary> /// Copies the input property, as-is, for the property value /// </summary> /// <typeparam name="TInput"></typeparam> /// <typeparam name="TProperty"></typeparam> public class InputDictionaryPropertyProvider<TInput, TProperty> : IPropertyProvider<TInput, TProperty> where TInput : class, IDictionary<string, TProperty> { readonly string _key; public InputDictionaryPropertyProvider(string key) { if (key == null) throw new ArgumentNullException(nameof(key)); _key = key; } public Task<TProperty> GetProperty<T>(InitializeContext<T, TInput> context) where T : class { if (context.HasInput && context.Input.TryGetValue(_key, out var value)) return Task.FromResult(value); return TaskUtil.Default<TProperty>(); } } }