protected virtual IEnumerable <Assembly> GetAssemblies(DotConfig config) { try { var skipPattern = config.AssemblySkipPattern; var restrictPattern = config.AssemblyRestrictPattern; var isWebApplication = config.IsWebApplication; var assemblies = AssemblyUtil.GetAssemblies(isWebApplication); if (!string.IsNullOrEmpty(skipPattern) && !string.IsNullOrEmpty(restrictPattern)) { return(assemblies.Where(t => t.FullName.IsNotMatch(skipPattern) && t.FullName.IsMatch(restrictPattern))); } if (!string.IsNullOrEmpty(skipPattern)) { return(assemblies.Where(t => t.FullName.IsNotMatch(skipPattern))); } if (!string.IsNullOrEmpty(restrictPattern)) { return(assemblies.Where(t => t.FullName.IsMatch(restrictPattern))); } return(assemblies); } catch { return(Enumerable.Empty <Assembly>()); } }
protected void RegistrationRegister(ContainerBuilder builder, DotConfig config) { var assemblies = this.GetAssemblies(config); var registrations = Registration.Scan(assemblies).ToArray(); this.DoRegistrationRegister(builder, registrations); }
public EngineBase(DotConfig config) { Ensure.NotNull <DotConfig>(config, "config"); var builder = new ContainerBuilder(); this.CustomRegister(builder, config); // 用户自定义注册,扩展点 this.RegistrationRegister(builder, config); // 自动注册 RegistrationAttribute _container = builder.Build(); }
protected override void CustomRegister(ContainerBuilder builder, DotConfig config) { }
public DotEngine(DotConfig config = null) : base(config) { }
protected abstract void CustomRegister(ContainerBuilder builder, DotConfig config);