public void ConstrainsForOpenGenerics(IContainerAdapter adapter)
        {
            adapter.RegisterTransient(typeof(IGenericService<>), typeof(GenericService<>));
            adapter.RegisterTransient(typeof(IGenericService<>), typeof(GenericServiceWithIService2Constraint<>));
            var resolved = adapter.ResolveAll<IGenericService<IndependentService>>().ToArray();

            Assert.Equal(1, resolved.Length);
            Assert.IsType<GenericService<IndependentService>>(resolved[0]);
        }
Exemplo n.º 2
0
        public void ConstrainsForOpenGenerics(IContainerAdapter adapter)
        {
            adapter.RegisterTransient(typeof(IGenericService <>), typeof(GenericService <>));
            adapter.RegisterTransient(typeof(IGenericService <>), typeof(GenericServiceWithIService2Constraint <>));
            var resolved = adapter.ResolveAll <IGenericService <IndependentService> >().ToArray();

            Assert.Equal(1, resolved.Length);
            Assert.IsType <GenericService <IndependentService> >(resolved[0]);
        }
Exemplo n.º 3
0
 public static IEnumerable <TService> ResolveAll <TService>(this IContainerAdapter container)
 {
     return(container.ResolveAll(typeof(TService)).Cast <TService>());
 }