示例#1
0
 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;
     })));
 }
示例#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;
     });
 }
示例#3
0
 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;
     }));
 }
示例#4
0
 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))));
 }
示例#5
0
 public MatchingExtensionPoint(IGetTheValueOfAProperty <ItemToMatch, Property> accessor)
 {
     this.accessor = accessor;
 }
示例#6
0
 public SummingVisitor(IGetTheValueOfAProperty <Element, Result> accessor, Func <Result, Result, Result> accumulator)
 {
     this.accessor    = accessor;
     this.accumulator = accumulator;
 }
示例#7
0
文件: Match.cs 项目: lawrencel/prep
 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));
 }
示例#8
0
 public ReducingVisitor(IGetTheValueOfAProperty <Element, Result> accessor, Func <Result, Result, Result> reducer)
 {
     this.reducer  = reducer;
     this.accessor = accessor;
     first_result  = true;
 }
示例#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));
 }
示例#10
0
 public static ICompareTwoItems <Item> by <Property>(IGetTheValueOfAProperty <Item, Property> accessor)
     where Property : IComparable <Property>
 {
     return(by(accessor, SortOrders.@ascending));
 }
示例#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)));
 }
示例#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)));
 }
示例#13
0
 with_attribute <Property>(IGetTheValueOfAProperty <Item, Property> accessor)
 {
     return(new MatchCreationExtensionPoint <Item, Property>(accessor));
 }
示例#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;
 }
示例#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));
 }
示例#17
0
 public PropertyMatcher(IGetTheValueOfAProperty <Item, Property> get_the_value,
                        Criteria <Property> property_criteria)
 {
     this.get_the_value     = get_the_value;
     this.property_criteria = property_criteria;
 }
示例#18
0
 public MatchFactory(IGetTheValueOfAProperty <Item, Property> accessor)
 {
     this.accessor = accessor;
 }