Пример #1
0
        public void Initialize(EasyErpConfig config)
        {
            RegisterDependencies(config);

            if (!config.IgnoreStartupTasks)
            {
                RunStartupTasks();
            }
        }
Пример #2
0
        protected virtual void RegisterDependencies(EasyErpConfig config)
        {
            var builder   = new ContainerBuilder();
            var container = builder.Build();

            //dependencies
            var typeFinder = new WebAppTypeFinder(config);

            builder = new ContainerBuilder();
            builder.RegisterInstance(config).As <EasyErpConfig>().SingleInstance();
            builder.RegisterInstance(this).As <IEngine>().SingleInstance();
            builder.RegisterInstance(typeFinder).As <ITypeFinder>().SingleInstance();
            builder.Update(container);

            //register dependencies provided by other assemblies
            builder = new ContainerBuilder();
            var drTypes     = typeFinder.FindClassesOfType <IDependencyRegistrar>();
            var drInstances = new List <IDependencyRegistrar>();

            foreach (var drType in drTypes)
            {
                drInstances.Add((IDependencyRegistrar)Activator.CreateInstance(drType));
            }

            //sort
            drInstances = drInstances.AsQueryable().OrderBy(t => t.Order).ToList();
            foreach (var dependencyRegistrar in drInstances)
            {
                dependencyRegistrar.Register(builder, typeFinder);
            }
            builder.Update(container);

            ContainerManager = new ContainerManager(container);

            //set dependency resolver
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
Пример #3
0
 public WebAppTypeFinder(EasyErpConfig config)
 {
     ensureBinFolderAssembliesLoaded = config.DynamicDiscovery;
 }