public static Result max <Element, Result>(this IEnumerable <Element> items,
                                            IGetTheValueOfAProperty <Element, Result> accessor)
     where Result : IComparable <Result>
 {
     return(items.get_result_of_processing_all_with(new ReducingVisitor <Element, Result>(accessor, (a, b) =>
     {
         return a.CompareTo(b) > 0 ? a : b;
     })));
 }
Exemple #2
0
 public static ICompareTwoItems <Item> then_by <Item, Property>(this ICompareTwoItems <Item> previous_comparer,
                                                                IGetTheValueOfAProperty <Item, Property> accessor, ICompareTwoItems <Property> order)
     where Property : IComparable <Property>
 {
     return((a, b) =>
     {
         var previous_result = previous_comparer(a, b);
         return previous_result == 0 ? Sort <Item> .by(accessor, order)(a, b) : previous_result;
     });
 }
 public static IProcessAndReturnAValue <Element, Result> create_summing_visitor <Element, Result>(
     IGetTheValueOfAProperty <Element, Result> accessor)
 {
     return(new SummingVisitor <Element, Result>(accessor,
                                                 (x, y) =>
     {
         dynamic first = x;
         dynamic second = y;
         return first + second;
     }));
 }
 public static Result avg <Element, Result>(this IEnumerable <Element> items,
                                            IGetTheValueOfAProperty <Element, Result> accessor)
 {
     return(items.get_result_of_processing_all_with(
                new AvgVisitor <Element, Result>(create_summing_visitor(accessor))));
 }
Exemple #5
0
 public MatchingExtensionPoint(IGetTheValueOfAProperty <ItemToMatch, Property> accessor)
 {
     this.accessor = accessor;
 }
Exemple #6
0
 public SummingVisitor(IGetTheValueOfAProperty <Element, Result> accessor, Func <Result, Result, Result> accumulator)
 {
     this.accessor    = accessor;
     this.accumulator = accumulator;
 }
Exemple #7
0
 public static MatchingExtensionPoint <ItemToMatch, Property> with_attribute <Property>(
     IGetTheValueOfAProperty <ItemToMatch, Property> get_the_value_of_a_property)
 {
     return(new MatchingExtensionPoint <ItemToMatch, Property>(get_the_value_of_a_property));
 }
 public ReducingVisitor(IGetTheValueOfAProperty <Element, Result> accessor, Func <Result, Result, Result> reducer)
 {
     this.reducer  = reducer;
     this.accessor = accessor;
     first_result  = true;
 }
Exemple #9
0
 public static ICompareTwoItems <Item> then_by_descending <Item, Property>(this ICompareTwoItems <Item> previous_comparer,
                                                                           IGetTheValueOfAProperty <Item, Property> accessor)
     where Property : IComparable <Property>
 {
     return(previous_comparer.then_by(accessor, SortOrders.descending));
 }
Exemple #10
0
 public static ICompareTwoItems <Item> by <Property>(IGetTheValueOfAProperty <Item, Property> accessor)
     where Property : IComparable <Property>
 {
     return(by(accessor, SortOrders.@ascending));
 }
Exemple #11
0
 public static ICompareTwoItems <Item> by <Property>(IGetTheValueOfAProperty <Item, Property> accessor,
                                                     params Property[] sort_order)
 {
     return((a, b) => Array.IndexOf(sort_order, accessor(a)) - Array.IndexOf(sort_order, accessor(b)));
 }
Exemple #12
0
 public static ICompareTwoItems <Item> by <Property>(IGetTheValueOfAProperty <Item, Property> accessor,
                                                     ICompareTwoItems <Property> order)
     where Property : IComparable <Property>
 {
     return((a, b) => order(accessor(a), accessor(b)));
 }
Exemple #13
0
 with_attribute <Property>(IGetTheValueOfAProperty <Item, Property> accessor)
 {
     return(new MatchCreationExtensionPoint <Item, Property>(accessor));
 }
Exemple #14
0
 public MatchCreationExtensionPoint(IGetTheValueOfAProperty <Item, Property> accessor)
 {
     this.accessor = accessor;
 }
 public EnumerableFilterExtensionPoint(IEnumerable <ItemToMatch> items_to_filter,
                                       IGetTheValueOfAProperty <ItemToMatch, PropertyType> accessor)
 {
     this.items_to_filter = items_to_filter;
     this.accessor        = accessor;
 }
Exemple #16
0
 public static EnumerableFilterExtensionPoint <Item, ItemProperty> filter <Item, ItemProperty>(
     this IEnumerable <Item> enumerable,
     IGetTheValueOfAProperty <Item, ItemProperty> accessor)
 {
     return(new EnumerableFilterExtensionPoint <Item, ItemProperty>(enumerable, accessor));
 }
 public PropertyMatcher(IGetTheValueOfAProperty <Item, Property> get_the_value,
                        Criteria <Property> property_criteria)
 {
     this.get_the_value     = get_the_value;
     this.property_criteria = property_criteria;
 }
Exemple #18
0
 public MatchFactory(IGetTheValueOfAProperty <Item, Property> accessor)
 {
     this.accessor = accessor;
 }