/
vshmidt
/
masstransit
Обзор
Документация
Войти
/
vshmidt
/
masstransit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/MassTransit/Initializers/PropertyProviders/VariablePropertyProvider.cs
45 строк
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.PropertyProviders { 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> /// <typeparam name="TValue"></typeparam> public class VariablePropertyProvider<TInput, TProperty, TValue> : IPropertyProvider<TInput, TValue> where TInput : class where TProperty : class, IInitializerVariable<TValue> { readonly IPropertyProvider<TInput, TProperty> _provider; public VariablePropertyProvider(IPropertyProvider<TInput, TProperty> provider) { _provider = provider; } public Task<TValue> GetProperty<T>(InitializeContext<T, TInput> context) where T : class { if (!context.HasInput) return TaskUtil.Default<TValue>(); Task<TProperty> propertyTask = _provider.GetProperty(context); if (propertyTask.Status == TaskStatus.RanToCompletion) return propertyTask.Result.GetValue(context); async Task<TValue> GetPropertyAsync() { var property = await propertyTask.ConfigureAwait(false); return await property.GetValue(context).ConfigureAwait(false); } return GetPropertyAsync(); } } }