/// <summary> /// Register a class with Autofac. /// </summary> /// <param name="autofacConfig">Autfac config information</param> public static void RegisterTypesFromAssembly(ThirdPartyAutofacConfiguration autofacConfig) { var assembly = Assembly.Load(autofacConfig.AssemblyName); if (autofacConfig.RegisterAll) { _builder.RegisterAssemblyTypes(assembly); } else if (autofacConfig.Singleton) { _builder.RegisterAssemblyTypes(assembly) .Where(t => t.Name.Equals(autofacConfig.Type)) .SingleInstance(); } else { _builder.RegisterAssemblyTypes(assembly) .Where(t => t.Name.Equals(autofacConfig.Type)) .AsImplementedInterfaces(); } }
/// <summary> /// Register a class with Autofac. /// </summary> /// <param name="autofacConfig">Autofac config info</param> public static void RegisterModulesFromAssembly(ThirdPartyAutofacConfiguration autofacConfig) { var assembly = Assembly.Load(autofacConfig.AssemblyName); _builder.RegisterAssemblyModules(assembly); }