Пример #1
0
        public static void Initialise()
        {
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AsImplementedInterfaces();
            builder.Register<ILogger>(c => Logger.GetLoggingService());

            IContainer serviceContainer = builder.Build(Autofac.Builder.ContainerBuildOptions.Default);
            IServiceLocator provider = new AutofacContrib.CommonServiceLocator.AutofacServiceLocator(serviceContainer);
            ServiceLocator.SetLocatorProvider(() => provider);
        }
Пример #2
0
        public static void Initialise()
        {
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AsImplementedInterfaces();
            builder.Register <ILogger>(c => Logger.GetLoggingService());

            IContainer      serviceContainer = builder.Build(Autofac.Builder.ContainerBuildOptions.Default);
            IServiceLocator provider         = new AutofacContrib.CommonServiceLocator.AutofacServiceLocator(serviceContainer);

            ServiceLocator.SetLocatorProvider(() => provider);
        }