public static void ScanPluginDirectory(this IAssemblyScanner scanner, Registry registry) { try { var cfg = ConfigurationManager.AppSettings["app:plugin-path"]; if (string.IsNullOrWhiteSpace(cfg)) { return; } var pluginsDirectory = Path.GetFullPath(cfg); if (!Directory.Exists(pluginsDirectory)) { return; } scanner.AssembliesFromPath(pluginsDirectory); scanner.LookForRegistries(); Type structureMapCheck = typeof(IServicePlugin); var assemblies = FindAssemblies(pluginsDirectory); foreach (var assembly in assemblies) { foreach (var type in assembly.GetExportedTypes().Where(a => !a.IsAbstract)) { if (!structureMapCheck.IsAssignableFrom(type)) { continue; } var interfaces = type.GetInterfaces(); foreach (var item in interfaces) { if (item == structureMapCheck) { continue; } registry.For(item).Use(type); } var baseType = type.BaseType; if (baseType == null || !baseType.IsAbstract) { continue; } registry.For(baseType).Use(type); } } } catch (Exception e) { var msg = e.Message; } }
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(); }
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(); }
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(); }
/// <summary> /// Called when StructureMap scans assemblies /// </summary> /// <param name="scanner">The <see cref="IAssemblyScanner"/></param> private static void OnScan(IAssemblyScanner scanner) { scanner.IgsAssemblies(); scanner.LookForRegistries(); }
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(); }