private static void WireUp <TMessageType>(IChainBuilder <TMessageType> chainBuilder, string propertyName) { if (string.IsNullOrWhiteSpace(propertyName)) { chainBuilder.NoDuplicates(msg => msg.ToString()); return; } SelectorSetup <TMessageType> .WireUp( propertyName, typeof(NoDuplicatesExtensions).GetMethods() .FirstOrDefault( m => m.IsGenericMethodDefinition && m.IsStatic && m.GetCustomAttributes <ExtensionMethodSelectorAttribute>().Any(a => a.Identifier == WireUpExtensionName)), (methodInfo, selector) => methodInfo.Invoke(null, new object[] { chainBuilder, selector })); }
protected override bool WireUpFromConfiguration <TMessageType, THandlerType>(DistinctConfiguration configuration, IChainBuilder <TMessageType> chainBuilder, THandlerType handler) { if (string.IsNullOrWhiteSpace(configuration.PropertyName)) { chainBuilder.Distinct(msg => msg.ToString()); return(true); } SelectorSetup <TMessageType> .WireUp( configuration.PropertyName, DistinctMethodInfo, (methodInfo, selector) => methodInfo.Invoke(null, new object[] { chainBuilder, selector })); return(true); }
protected override bool WireUpFromAttribute <TMessageType, THandlerType>( DistinctAttribute attribute, IChainBuilder <TMessageType> chainBuilder, THandlerType handler) { if (string.IsNullOrWhiteSpace(attribute.PropertyName)) { chainBuilder.Distinct(msg => msg); return(true); } SelectorSetup <TMessageType> .WireUp( attribute.PropertyName, DistinctMethodInfo, (typedMethodInfo, selector) => typedMethodInfo.Invoke(null, new object[] { chainBuilder, selector })); return(true); }