Exemplo n.º 1
0
        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 }));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }