static void ScannerConfiguration(IAssemblyScanner scanner) { scanner.TheCallingAssembly(); scanner.AssemblyContainingType(typeof(Secret)); scanner.SingleImplementationsOfInterface(); scanner.WithDefaultConventions(); // Using OnAddedPluginType doesn't make concrete types singletons by default. scanner.With(new SingletonConvention()); }
private void AddConventions(IAssemblyScanner scanner) { scanner.WithDefaultConventions(); Assembly .GetExecutingAssembly() .GetTypes() .Where(type => typeof(IRegistrationConvention).IsAssignableFrom(type)) .ToList() .ForEach(type => scanner.With(CreateConvention(type))); }
private void loadAssemblies(IAssemblyScanner obj) { obj.TheCallingAssembly(); obj.AssemblyContainingType <IProductRepository>(); // Core obj.Assembly("Infrastructure"); // the Infrastructure DLL obj.WithDefaultConventions(); obj.With(new ControllerConvention()); obj.LookForRegistries(); }
/// <summary> /// Uses <see cref="MessageHandlerConvention"/> on the scanner to auto-register found Rebus handlers /// </summary> public static void WithMessageHanderConvention(this IAssemblyScanner scanner) { scanner.With(new MessageHandlerConvention()); }
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 ConnectImplementationsToSingletonTypesClosing(this IAssemblyScanner assemblyScanner, Type openGenericType) { assemblyScanner.With(new GenericConnectionScannerWithScope(openGenericType, InstanceScope.Singleton)); }
/// <summary> /// Adds a convention to the scanner that looks for a writable property of a specified type /// and configures injection for it. Mostly useful for optional dependencies like loggers etc. /// </summary> public static SetAllPropertiesConvention WithSetAllPropertiesConvention(this IAssemblyScanner scanner) { return(scanner.With <SetAllPropertiesConvention>()); }
/// <summary> /// Adds a convention to the scanner that registers several types implementing the same interface. /// By default it is registered with the name of the type, but this can be overridden. /// </summary> public static AddAllConvention WithAddAllConvention(this IAssemblyScanner scanner) { return(scanner.With <AddAllConvention>()); }
/// <summary> /// Adds a convention to the scanner that registers all types by a naming convention. /// By default it tries to find an interface with the same name as the /// service, prefixed with an I, but this can be overridden. /// </summary> public static NamingConvention WithNamingConvention(this IAssemblyScanner scanner) { return(scanner.With <NamingConvention>()); }
/// <summary> /// Adds a convention to the scanner that registers all types by the first interface defined for the type. /// </summary> public static FirstInterfaceConvention WithFirstInterfaceConvention(this IAssemblyScanner scanner) { return(scanner.With <FirstInterfaceConvention>()); }
/// <summary> /// Adds a convention to the scanner that will look for and include all <see cref="UnityRegistry"/> derived classes it finds. /// </summary> public static ScanForRegistriesConvention ForRegistries(this IAssemblyScanner scanner) { return(scanner.With <ScanForRegistriesConvention>()); }
/// <summary> /// Scans for implementers or inheritors of T and registers them /// </summary> /// <typeparam name="T"></typeparam> /// <param name="scanner"></param> public static void WithPluginConvention <T>(this IAssemblyScanner scanner) { scanner.With(new CustomTypePluginConvention <T>()); }