/// <summary> /// Retrieves all bindings satisfying the constraints for the specified <see cref="Type"/>. /// </summary> public static void SatisfyConstraints(BindingCollection bindings, Type type, LinkList <Constraint> constraints) { Debug.Assert(bindings != null); Debug.Assert(type != null); Debug.Assert(constraints != null); bindings.Reduce(constraints, (b, c) => c.SatisfyCore(type, b)); }
public void Reduce_GivenCollectionProcessor_UpdatesAllBindings( ) { var initial = List(typeof(int)); var expected = new[] { List(typeof(Tuple <int>)) }; var collection = new BindingCollection(initial); collection.Reduce((b) => new[] { List(typeof(Tuple <>).MakeGenericType(b.Value.Type)) }); var actual = collection.ToArray( ); Assert.Equal(actual, expected); }
public void Reduce_GivenCollectionProcessor_UpdatesBindingsAgainstAllInputs( ) { var initial = List(typeof(int)); var expected = new[] { List(typeof(Tuple <Tuple <int> >)) }; var collection = new BindingCollection(initial); collection.Reduce(Enumerable.Repeat(1, 2), (b, i) => new[] { List(typeof(Tuple <>).MakeGenericType(b.Value.Type)) }); var actual = collection.ToArray( ); Assert.Equal(actual, expected); }
public void Reduce_GivenItemProcessor_RemovesBindingsWhenProcessorReturnsNull( ) { var initial = new[] { List(typeof(int)), List(typeof(double)) }; var expected = new[] { initial[1] }; var collection = new BindingCollection(initial); collection.Reduce(Enumerable.Repeat(1, 2), (b, i) => i == 1 && b.Value.Type == typeof(int) ? null : b); var actual = collection.ToArray( ); Assert.Equal(actual, expected); }