Example #1
0
        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>());
            }
        }
Example #2
0
        protected void RegistrationRegister(ContainerBuilder builder, DotConfig config)
        {
            var assemblies    = this.GetAssemblies(config);
            var registrations = Registration.Scan(assemblies).ToArray();

            this.DoRegistrationRegister(builder, registrations);
        }
Example #3
0
        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();
        }
Example #4
0
 protected override void CustomRegister(ContainerBuilder builder, DotConfig config)
 {
 }
Example #5
0
 public DotEngine(DotConfig config = null) : base(config)
 {
 }
Example #6
0
 protected abstract void CustomRegister(ContainerBuilder builder, DotConfig config);