/// <summary> /// Extension method to help with scanning assemblies in the solution for handler types /// </summary> /// <param name="scanner"></param> public static void ScanForHandlers(this IAssemblyScanner scanner) { scanner.TheCallingAssembly(); scanner.AssemblyContainingType <IHandlerBase>(); scanner.AssembliesFromApplicationBaseDirectory(); scanner.AddAllTypesOf <IHandlerBase>(); }
private void ScanTypes(IAssemblyScanner scanner) { scanner.AssembliesFromApplicationBaseDirectory(); scanner.AddAllTypesOf <ITask>(); // Logging For <ILogger>().Use(x => _logger); // Powershell For <IPowershellRunner>().Use <PowershellRunner>(); For <IFileProvider>().Use <FileProvider>(); // YAML For <IConfigFileReader>().Use <ConfigFileReader>(); For <Dictionary <string, ITask> >().Use("TasksAsDictionary", context => { return(TasksAsDictionary(context.GetAllInstances <ITask>())); }); For <IYamlConfigParser>().Use("IYamlConfigParser", context => { var configFileReader = context.GetInstance <IConfigFileReader>(); var tasks = context.GetInstance <Dictionary <string, ITask> >(); return(new YamlConfigParser(configFileReader, tasks, _logger)); }); }
public static void Scan(IAssemblyScanner scan) { var projectPrefix = ConfigurationManager.AppSettings["IoCProjectPrefix"]; scan.TheCallingAssembly(); scan.AssembliesFromApplicationBaseDirectory( y => y.FullName.StartsWith(projectPrefix) && !y.FullName.EndsWith("Tests")); scan.AddAllTypesOf(typeof(IRepository <>)); scan.ConnectImplementationsToTypesClosing(typeof(IRepository <>)); scan.WithDefaultConventions(); scan.LookForRegistries(); }
/// <summary> /// Performs a scan to automatically map interfaces to concrete types. /// </summary> /// <param name="assemblyScanner"> /// An instance of <see cref="IAssemblyScanner" />. /// </param> private void DoScan(IAssemblyScanner assemblyScanner) { // Always create concrete instances based on usual DI naming // convention // i.e. Search for class name "Concrete" when "IConcrete" is // requested. assemblyScanner.WithDefaultConventions(); // Scan the calling assembly. assemblyScanner.TheCallingAssembly(); // And all other Meridian assemblies. assemblyScanner.AssembliesFromApplicationBaseDirectory( x => x.FullName.StartsWith("Meridian")); }
private void ScanTypes(IAssemblyScanner scanner) { scanner.TheCallingAssembly(); scanner.AssembliesFromApplicationBaseDirectory(assembly => assembly.FullName.Contains("Roadkill")); scanner.SingleImplementationsOfInterface(); scanner.WithDefaultConventions(); // Scan plugins: this includes everything e.g repositories, UserService, FileService TextPlugins CopyPlugins(ApplicationSettings); foreach (string subDirectory in Directory.GetDirectories(ApplicationSettings.PluginsBinPath)) { scanner.AssembliesFromPath(subDirectory); } // Plugins scanner.With(new AbstractClassConvention <TextPlugin>()); scanner.With(new AbstractClassConvention <SpecialPagePlugin>()); scanner.AddAllTypesOf <IPluginFactory>(); // Config, context scanner.AddAllTypesOf <ApplicationSettings>(); scanner.AddAllTypesOf <IUserContext>(); // Repositories scanner.AddAllTypesOf <ISettingsRepository>(); scanner.AddAllTypesOf <IUserRepository>(); scanner.AddAllTypesOf <IPageRepository>(); // Services scanner.With(new AbstractClassConvention <UserServiceBase>()); scanner.AddAllTypesOf <IPageService>(); scanner.AddAllTypesOf <ISearchService>(); scanner.AddAllTypesOf <ISettingsService>(); scanner.AddAllTypesOf <IActiveDirectoryProvider>(); scanner.AddAllTypesOf <IFileService>(); scanner.AddAllTypesOf <IInstallationService>(); // Text parsers scanner.AddAllTypesOf <MarkupConverter>(); scanner.AddAllTypesOf <CustomTokenParser>(); // MVC Related scanner.AddAllTypesOf <UserViewModel>(); scanner.AddAllTypesOf <SettingsViewModel>(); scanner.AddAllTypesOf <AttachmentRouteHandler>(); scanner.AddAllTypesOf <ISetterInjected>(); scanner.AddAllTypesOf <IAuthorizationAttribute>(); scanner.AddAllTypesOf <RoadkillLayoutPage>(); scanner.AddAllTypesOf(typeof(RoadkillViewPage <>)); scanner.ConnectImplementationsToTypesClosing(typeof(RoadkillViewPage <>)); // Emails scanner.AddAllTypesOf <SignupEmail>(); scanner.AddAllTypesOf <ResetPasswordEmail>(); // Cache scanner.AddAllTypesOf <ListCache>(); scanner.AddAllTypesOf <PageViewModelCache>(); // Export scanner.AddAllTypesOf <WikiExporter>(); // Controllers scanner.AddAllTypesOf <IRoadkillController>(); scanner.AddAllTypesOf <ControllerBase>(); scanner.AddAllTypesOf <ApiController>(); scanner.AddAllTypesOf <ConfigurationTesterController>(); }
public static void AssembliesFromApplicationBaseDirectory(this IAssemblyScanner scanner) { scanner.AssembliesFromApplicationBaseDirectory(a => true); }
void ScanForRegistries(IAssemblyScanner scanner) { scanner.AssembliesFromApplicationBaseDirectory(f => f.FullName.StartsWith(SolutionPrefix)); scanner.WithDefaultConventions(); scanner.LookForRegistries(); }
private static void Scan(IAssemblyScanner s) { s.AssembliesFromApplicationBaseDirectory(); s.LookForRegistries(); s.WithDefaultConventions(); }
public static void AssembliesForApplication(this IAssemblyScanner scanner) { scanner.AssembliesFromApplicationBaseDirectory(Filter); }
private static void PerformScan(IAssemblyScanner scanner) { scanner.AssembliesFromApplicationBaseDirectory(); scanner.Include(type => type.HasAttribute<UnitWorkerAttribute>()); scanner.Convention<HttpContextLifecycleConvention>(); }