Пример #1
0
        protected override void Load(ContainerBuilder builder)
        {
            if (Config.IocAssembly.IsNotNullOrEmpty())
            {
                Config.IocAssembly.Split(',').Each(t => builder
                                                   .RegisterAssemblyTypes(AssemblyUtil.GetAllProjectAssemblies(t.ToString().Trim()))
                                                   .AsImplementedInterfaces()
                                                   .PropertiesAutowired());
            }

            if (Config.ApiHost.IsNotNullOrEmpty())
            {
                var api = AssemblyUtil.GetAllProjectAssemblies(Config.ApiHost);
                if (api != null)
                {
                    builder.RegisterApiControllers(api);
                }
            }

            if (Config.Controllers.IsNotNullOrEmpty())
            {
                var mvc = AssemblyUtil.GetAllProjectAssemblies(Config.Controllers);
                if (mvc != null)
                {
                    builder.RegisterControllers(mvc);
                }
            }
            builder.RegisterFilterProvider();
        }
Пример #2
0
        public static void Configure(IContainer container, string assemblyPrefix = "GS")
        {
            var builder    = new ContainerBuilder();
            var assemblies = AssemblyUtil.GetAllProjectAssemblies(assemblyPrefix);

            builder.RegisterAssemblyModules(assemblies);
            builder.Update(container);
        }