public void Register(IMethodCallBinder binder, Func<MethodCallExpression, bool> filter, params string[] names) { if (names == null) { return; } foreach (var name in names) { List<KeyValuePair<Registration, IMethodCallBinder>> namedBinders; if (!_binders.TryGetValue(name, out namedBinders)) { _binders[name] = namedBinders = new List<KeyValuePair<Registration, IMethodCallBinder>>(); } namedBinders.Add( new KeyValuePair<Registration, IMethodCallBinder>( new Registration(name, filter), binder)); } }
public void Register(IMethodCallBinder binder, params string[] names) { Register(binder, node => true, names); }
protected PipelineBinderBase(TBindingContext bindingContext, IMethodCallBinder <TBindingContext> methodCallBinder) { _bindingContext = Ensure.IsNotNull(bindingContext, nameof(bindingContext)); _methodCallBinder = Ensure.IsNotNull(methodCallBinder, nameof(methodCallBinder)); }
public ProjectionBindingContext(IBsonSerializerRegistry serializerRegistry, IMethodCallBinder methodCallBinder) { _serializerRegistry = Ensure.IsNotNull(serializerRegistry, "serializerRegistry"); _methodCallBinder = Ensure.IsNotNull(methodCallBinder, "methodCallBinder"); _groupMap = new CorrelatedGroupMap(); }
static ProjectionBinder() { var nameBasedBinder = new NameBasedMethodCallBinder(); nameBasedBinder.Register(new AnyBinder(), "Any", "AnyAsync"); nameBasedBinder.Register(new AverageBinder(), "Average", "AverageAsync"); nameBasedBinder.Register(new CountBinder(), "Count", "CountAsync", "LongCount", "LongCountAsync"); nameBasedBinder.Register(new DistinctBinder(), node => node.Arguments.Count == 1, "Distinct"); nameBasedBinder.Register(new FirstBinder(), "First", "FirstAsync", "FirstOrDefault", "FirstOrDefaultAsync"); nameBasedBinder.Register(new CorrelatedGroupByBinder(), node => node.Arguments.Count == 2 && ExtensionExpressionVisitor.IsLambda(node.Arguments[1], 1), "GroupBy"); nameBasedBinder.Register(new GroupByWithResultSelectorBinder(), node => node.Arguments.Count == 3 && ExtensionExpressionVisitor.IsLambda(node.Arguments[1], 1) && ExtensionExpressionVisitor.IsLambda(node.Arguments[2], 2), "GroupBy"); nameBasedBinder.Register(new MaxBinder(), "Max", "MaxAsync"); nameBasedBinder.Register(new MinBinder(), "Min", "MinAsync"); nameBasedBinder.Register(new OfTypeBinder(), "OfType"); nameBasedBinder.Register(new OrderByBinder(), node => node.Arguments.Count == 2 && ExtensionExpressionVisitor.IsLambda(node.Arguments[1], 1), "OrderBy", "OrderByDescending", "ThenBy", "ThenByDescending"); nameBasedBinder.Register(new SelectBinder(), node => node.Arguments.Count == 2 && ExtensionExpressionVisitor.IsLambda(node.Arguments[1], 1), "Select"); nameBasedBinder.Register(new SelectManyBinder(), node => node.Arguments.Count == 2 && ExtensionExpressionVisitor.IsLambda(node.Arguments[1], 1), "SelectMany"); nameBasedBinder.Register(new SelectManyBinder(), node => node.Arguments.Count == 3 && ExtensionExpressionVisitor.IsLambda(node.Arguments[1], 1) && ExtensionExpressionVisitor.IsLambda(node.Arguments[2], 2), "SelectMany"); nameBasedBinder.Register(new SingleBinder(), "Single", "SingleAsync", "SingleOrDefault", "SingleOrDefaultAsync"); nameBasedBinder.Register(new SkipBinder(), "Skip"); nameBasedBinder.Register(new TakeBinder(), "Take"); nameBasedBinder.Register(new SumBinder(), "Sum", "SumAsync"); nameBasedBinder.Register(new WhereBinder(), node => node.Arguments.Count == 2 && ExtensionExpressionVisitor.IsLambda(node.Arguments[1], 1), "Where"); __methodCallBinder = nameBasedBinder; }
private ProjectionBinder(IBsonSerializer documentSerializer, IBsonSerializerRegistry serializerRegistry, IMethodCallBinder methodCallBinder) { _methodCallBinder = Ensure.IsNotNull(methodCallBinder, "methodCallBinder"); _documentSerializer = Ensure.IsNotNull(documentSerializer, "documentSerializer"); _context = new ProjectionBindingContext( Ensure.IsNotNull(serializerRegistry, "serializerRegistry"), _methodCallBinder); }