/// <summary> /// Injects Singleton, Scoped or Transient mappings based on the supplied parameters /// </summary> /// <param name="services"></param> /// <param name="rootNamespace">Root namespace to poll for interfaces</param> /// <param name="interfaceSuffixList">Suffixes for injectable interfaces</param> /// <param name="interfacePrefix">Prefix for injectable interfaces</param> /// <param name="enforceStrictNaming">If true, will only inject concrete types whos class names are {interfacePrefix}{ConcreteClassName}{InterfaceSuffix}</param> /// <param name="restrictImplementationsToInterfaceNamespaces">If true, will only map interfaces to concrete classes in the same root namespace</param> private static IServiceCollection InjectFrom(this IServiceCollection services, InjectionMode mode, string rootNamespace, List <string> interfaceSuffixList, string interfacePrefix = "I", bool enforceStrictNaming = true, bool restrictImplementationsToInterfaceNamespaces = false) { var settings = new InjectionSettings { EnforceStrictNaming = enforceStrictNaming, InjectionMode = mode, InterfaceRootNamespaces = new List <string> { rootNamespace }, InterfacePrefix = interfacePrefix, InterfaceSuffixList = interfaceSuffixList, RestrictImplementationsToInterfaceNamespaces = restrictImplementationsToInterfaceNamespaces }; return(services.InjectByConvention(settings)); }
public static IInjectionRootNamespaceConfiguration WithInjectionMode(InjectionMode mode) { var settings = new InjectionSettings(); return(((IInjectionModeConfiguration)settings).WithInjectionMode(mode)); }