Пример #1
0
 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());
 }
Пример #2
0
        private void AddConventions(IAssemblyScanner scanner)
        {
            scanner.WithDefaultConventions();

            Assembly
                .GetExecutingAssembly()
                .GetTypes()
                .Where(type => typeof(IRegistrationConvention).IsAssignableFrom(type))
                .ToList()
                .ForEach(type => scanner.With(CreateConvention(type)));
        }
Пример #3
0
        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 all assemblies, including the one executing.
            assemblyScanner.AssembliesFromPath(this.executingAssemblyLocation);
        }
        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();
        }
Пример #5
0
        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();
        }
Пример #6
0
        /// <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 static void ScanAssemblies(IAssemblyScanner scanner)
        {
            var assebliesToBeScanned = ConfigurationManager.AppSettings["AssembliesToBeScanned"];
            List<string> assemblies = null;
            if (assebliesToBeScanned != null)
            {
                assemblies = assebliesToBeScanned.Split(';').ToList();
            }

            if (assemblies != null)
            {
                assemblies.ForEach(scanner.Assembly);
            }

            scanner.WithDefaultConventions();
            scanner.TheCallingAssembly();
            scanner.LookForRegistries();
        }
        private static void ScanAssemblies(IAssemblyScanner scanner)
        {
            var           assebliesToBeScanned = ConfigurationManager.AppSettings["AssembliesToBeScanned"];
            List <string> assemblies           = null;

            if (assebliesToBeScanned != null)
            {
                assemblies = assebliesToBeScanned.Split(';').ToList();
            }

            if (assemblies != null)
            {
                assemblies.ForEach(scanner.Assembly);
            }

            scanner.WithDefaultConventions();
            scanner.TheCallingAssembly();
            scanner.LookForRegistries();
        }
Пример #9
0
 private static void Initialize(IAssemblyScanner scan)
 {
     scan.WithDefaultConventions();
     scan.TheCallingAssembly();
     scan.AssemblyContainingType(typeof(Microsoft.TeamFoundation.Client.TeamFoundationServer));
 }
Пример #10
0
 private static void Initialize(IAssemblyScanner scan)
 {
     scan.WithDefaultConventions();
     scan.TheCallingAssembly();
 }
Пример #11
0
        private void Scan(IAssemblyScanner scanner)
        {
            scanner.TheCallingAssembly();
            scanner.SingleImplementationsOfInterface();
            scanner.WithDefaultConventions();

            // Copy all plugins to the /bin/Plugins folder
            CopyPlugins();

            // Scan plugins
            foreach (string subDirectory in Directory.GetDirectories(_applicationSettings.PluginsBinPath))
            {
                scanner.AssembliesFromPath(subDirectory);
            }

            // UserServiceBase is scanned below
            // Scan for TextPlugins
            scanner.AddAllTypesOf <TextPlugin>();

            // Scan for SpecialPages
            scanner.AddAllTypesOf <SpecialPagePlugin>();

            // The pluginfactory
            scanner.AddAllTypesOf <IPluginFactory>();

            // Config, repository, context
            scanner.AddAllTypesOf <ApplicationSettings>();
            scanner.AddAllTypesOf <IRepository>();
            scanner.AddAllTypesOf <IUserContext>();

            // Services and services
            scanner.AddAllTypesOf <ServiceBase>();
            scanner.AddAllTypesOf <IPageService>();
            scanner.AddAllTypesOf <IActiveDirectoryProvider>();
            scanner.AddAllTypesOf <UserServiceBase>();

            // Text parsers
            scanner.AddAllTypesOf <MarkupConverter>();
            scanner.AddAllTypesOf <CustomTokenParser>();

            // MVC Related
            scanner.AddAllTypesOf <Roadkill.Core.Mvc.Controllers.Api.ApiControllerBase>();
            scanner.AddAllTypesOf <Roadkill.Core.Mvc.Controllers.ControllerBase>();
            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>();
        }
Пример #12
0
        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>();
        }
Пример #13
0
 void ScanForRegistries(IAssemblyScanner scanner)
 {
     scanner.AssembliesFromApplicationBaseDirectory(f => f.FullName.StartsWith(SolutionPrefix));
     scanner.WithDefaultConventions();
     scanner.LookForRegistries();
 }
Пример #14
0
 private static void Scan(IAssemblyScanner s)
 {
     s.AssembliesFromApplicationBaseDirectory();
     s.LookForRegistries();
     s.WithDefaultConventions();
 }
Пример #15
0
 public static void UseDefaultConventions <T>(IAssemblyScanner scan)
 {
     scan.AssemblyContainingType <T>();
     scan.WithDefaultConventions();
 }
Пример #16
0
 private static void Initialize(IAssemblyScanner scan)
 {
     scan.WithDefaultConventions();
     scan.TheCallingAssembly();
 }
Пример #17
0
 private static void FindAllStructureMapPlugins(IAssemblyScanner x)
 {
     x.AssemblyContainingType<Bootstrapper>();
      x.TheCallingAssembly();
      x.WithDefaultConventions();
 }
Пример #18
0
        private void Scan(IAssemblyScanner scanner)
        {
            scanner.TheCallingAssembly();
            scanner.SingleImplementationsOfInterface();
            scanner.WithDefaultConventions();

            // Copy all plugins to the /bin/Plugins folder
            CopyPlugins();

            // Scan plugins
            foreach (string subDirectory in Directory.GetDirectories(_applicationSettings.PluginsBinPath))
            {
                scanner.AssembliesFromPath(subDirectory);
            }

            // UserServiceBase is scanned below
            // Scan for TextPlugins
            scanner.AddAllTypesOf<TextPlugin>();

            // Scan for SpecialPages
            scanner.AddAllTypesOf<SpecialPagePlugin>();

            // The pluginfactory
            scanner.AddAllTypesOf<IPluginFactory>();

            // Config, repository, context
            scanner.AddAllTypesOf<ApplicationSettings>();
            scanner.AddAllTypesOf<IRepository>();
            scanner.AddAllTypesOf<IUserContext>();

            // Services and services
            scanner.AddAllTypesOf<ServiceBase>();
            scanner.AddAllTypesOf<IPageService>();
            scanner.AddAllTypesOf<IActiveDirectoryProvider>();
            scanner.AddAllTypesOf<UserServiceBase>();
            scanner.AddAllTypesOf<IFileService>();

            // Text parsers
            scanner.AddAllTypesOf<MarkupConverter>();
            scanner.AddAllTypesOf<CustomTokenParser>();

            // MVC Related
            scanner.AddAllTypesOf<Roadkill.Core.Mvc.Controllers.Api.ApiControllerBase>();
            scanner.AddAllTypesOf<Roadkill.Core.Mvc.Controllers.ControllerBase>();
            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>();
        }