/// <summary> /// Load the message data as part of the transform (replaces the property on the original message, to avoid multiple /// loads of the same data). /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="TProperty"></typeparam> /// <param name="configurator"></param> /// <param name="propertyExpression"></param> /// <param name="repository"></param> public static void LoadMessageData <T, TProperty>(this ITransformConfigurator <T> configurator, Expression <Func <T, TProperty> > propertyExpression, IMessageDataRepository repository) { var configuration = new LoadMessageDataTransformConfiguration <T, TProperty>(repository, propertyExpression.GetPropertyInfo()); configuration.Apply(configurator); }
public void Apply(ITransformConfigurator <TInput> configurator) { var inputPropertyProvider = new InputPropertyProvider <TInput, MessageData <TValue> >(_property); var provider = new GetMessageDataPropertyProvider <TInput, TValue>(inputPropertyProvider, _repository); configurator.Set(_property, provider); }
public void Apply(ITransformConfigurator <TInput> configurator) { if (_transformConfigurator.TryGetConverter(out var converter)) { var inputPropertyProvider = new InputPropertyProvider <TInput, TProperty>(_property); var provider = new PropertyConverterPropertyProvider <TInput, TProperty, TProperty>(converter, inputPropertyProvider); configurator.Transform(_property, provider); } }
public void Apply(ITransformConfigurator <TInput> configurator) { if (TypeMetadataCache <TInput> .IsValidMessageType) { var inputPropertyProvider = new InputPropertyProvider <TInput, MessageData <TValue> >(_property); var provider = new PutMessageDataPropertyProvider <TInput, TValue>(inputPropertyProvider, _repository); configurator.Set(_property, provider); } }
public void Apply(ITransformConfigurator <TInput> configurator) { if (_transformConfigurator.TryGetConverter(out var converter)) { var inputPropertyProvider = new InputPropertyProvider <TInput, TProperty>(_property); var dictionaryConverter = new DictionaryPropertyConverter <TKey, TValue, TValue>(converter) as IPropertyConverter <TProperty, TProperty>; var provider = new PropertyConverterPropertyProvider <TInput, TProperty, TProperty>(dictionaryConverter, inputPropertyProvider); configurator.Set(_property, provider); } }
static void LoadMessageData <T>(this ITransformConfigurator <T> configurator, IMessageDataRepository repository) { List <PropertyInfo> messageDataProperties = TypeMetadataCache <T> .Properties.Where(x => x.PropertyType.HasInterface <IMessageData>()).ToList(); foreach (PropertyInfo messageDataProperty in messageDataProperties) { Type dataType = messageDataProperty.PropertyType.GetClosingArguments(typeof(MessageData <>)).First(); Type providerType = typeof(LoadMessageDataTransformConfiguration <,>).MakeGenericType(typeof(T), dataType); var configuration = (IMessageDataTransformConfiguration <T>)Activator.CreateInstance(providerType, repository, messageDataProperty); configuration.Apply(configurator); } }
public void Apply(ITransformConfigurator <TInput> configurator) { if (_transformConfigurator.TryGetConverter(out var converter)) { var inputPropertyProvider = new InputPropertyProvider <TInput, TProperty>(_property); IPropertyConverter <TProperty, TProperty> arrayConverter = typeof(TProperty).IsArray ? new ArrayPropertyConverter <TElement, TElement>(converter) as IPropertyConverter <TProperty, TProperty> : new ListPropertyConverter <TElement, TElement>(converter) as IPropertyConverter <TProperty, TProperty>; var provider = new PropertyConverterPropertyProvider <TInput, TProperty, TProperty>(arrayConverter, inputPropertyProvider); configurator.Transform(_property, provider); } }
public void Apply(ITransformConfigurator <TInput> configurator) { var provider = new LoadMessageDataPropertyProvider <TInput, TValue>(_repository, _property); configurator.Replace(_property, provider); }