[代码] 系统启动:创建注册类,然后传入必要的Assembly,调用注册机注册所有加了Attribute的类。

using System;
using System.Collections.Generic;
using System.Reflection;
using Skight.eLiteWeb.Domain.Containers;
using Skight.eLiteWeb.Presentation.Web.FrontControllers;

namespace Skight.eLiteWeb.Application.Startup
{
    public class ApplicationStartup
    {
        public void run()
        {
            var registration = create_registration();
            new RegistrationScanner(registration,
                                               Assembly.GetAssembly(typeof (Container)),
                                               Assembly.GetAssembly(typeof (FrontController)),
                                               Assembly.GetAssembly(typeof (StartupCommand)))
                                               .run();

        }

        private Registration create_registration()
        {
            IDictionary<Type, DiscreteItemResolver> item_resolvers = new Dictionary<Type, DiscreteItemResolver>();
            Container.initialize_with(new ResolverImpl(item_resolvers));
            return new RegistrationImpl(item_resolvers);
        }
    }
}