예제 #1
0
        public void ConstrainsForOpenGenerics(IFrameworkAdapter framework)
        {
            framework.RegisterTransient(typeof(IGenericService <>), typeof(GenericService <>));
            framework.RegisterTransient(typeof(IGenericService <>), typeof(GenericServiceWithIService2Constraint <>));
            var resolved = framework.ResolveAll <IGenericService <IndependentService> >().ToArray();

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