private void IterateAndRegister(ILookup <RegistrationInfo, Type> lookup, Func <Type, bool> typePredicate, RegistrationTarget target) { if (lookup == null || typePredicate == null) { return; } var serviceTypeCondition = TargetResolver.Resolve(target); foreach (var group in lookup) { if (group.Key.Matches(RegistrationLifeTime.None)) { continue; } var matchingTypes = group.Where(t => t != null) .Where(typePredicate); var lifetime = group.Key.LifeTime.ToContainerLifeTime(); var key = group.Key.Key; _container.RegisterMany(matchingTypes, lifetime, serviceTypeCondition: serviceTypeCondition, serviceKey: ResolveKey(key)); } }
public IRegistrationContainer Register(Type concreteType, RegistrationTarget target, RegistrationLifeTime registrationLifeTime = RegistrationLifeTime.Transient, string key = null, bool shouldReplace = false) { var serviceTypeCondition = TargetResolver.Resolve(target); _container.RegisterMany(new[] { concreteType }, registrationLifeTime.ToContainerLifeTime(), serviceTypeCondition: serviceTypeCondition, serviceKey: ResolveKey(key), ifAlreadyRegistered: Map(shouldReplace)); return(this); }