Exemple #1
0
        /// <summary>
        /// Creates an instance of an IDependencyScanner
        /// </summary>

        /// <param name="assemblyLocator">The assembly locator.  This parameter is optional.  </param>
        /// <param name="assemblyTypeService">The assembly type service.  This parameter is optional</param>
        /// <returns></returns>
        public static IDependencyScanner Create(
            Func <IAssemblyLocator> assemblyLocator         = null,
            Func <IAssemblyTypeService> assemblyTypeService = null)
        {
            assemblyLocator     = assemblyLocator ?? (() => AssemblyLocatorFactory.Resolve());
            assemblyTypeService = assemblyTypeService ?? (() => AssemblyTypeFactory.Resolve());

            var defaultScanner = new DependencyScanner(assemblyLocator(),
                                                       assemblyTypeService());

            return(defaultScanner);
        }
Exemple #2
0
        /// <summary>
        /// Registers defaults implementations of all required services.
        /// </summary>
        /// <param name="services">The services.</param>
        private static IServiceCollection RegisterDefaults(IServiceCollection services)
        {
            var buildProvider = services.BuildServiceProvider();

            if (buildProvider.GetService <IDependencyScanner>() == null)
            {
                services.AddSingleton((t) => DependencyScannerFactory.Create());
            }
            if (buildProvider.GetService <IAssemblyLocator>() == null)
            {
                services.AddSingleton((t) => AssemblyLocatorFactory.Resolve());
            }
            if (buildProvider.GetService <IAssemblyTypeService>() == null)
            {
                services.AddSingleton((t) => AssemblyTypeFactory.Resolve());
            }

            return(services);
        }