private void AddTypes(IEnumerable <Type> types, IoCRegistrationType registrationType) { foreach (var type in types) { if (registrationType == IoCRegistrationType.Manual) { continue; } var implementing = type.GetImplementedInterfaces(true); if (registrationType == IoCRegistrationType.Transient) { foreach (var implementedType in implementing) { AddTransient(implementedType, type); } AddTransient(type); continue; } if (registrationType == IoCRegistrationType.Singleton) { foreach (var implementedType in implementing) { AddSingleton(implementedType, type); } AddSingleton(type); } } }
protected IEnumerable <Type> AddSweep(Type inheritedFrom, IoCRegistrationType registrationType) { var types = _createableTypes.Inherits(inheritedFrom); AddTypes(types, registrationType); return(types); }
protected IEnumerable <Type> AddSweep(string kind, IoCRegistrationType registrationType) { var types = _createableTypes.EndingWith(kind); AddTypes(types, registrationType); return(types); }
protected IEnumerable <Type> AddSweep <T>(IoCRegistrationType registrationType) => AddSweep(typeof(T), registrationType);