Пример #1
0
        protected override void SetupBuilder(Autofac.ContainerBuilder builder)
        {
            base.SetupBuilder(builder);

            builder.RegisterModule(new Zetbox.API.ApiModule());
            builder.RegisterModule(new Zetbox.API.Client.ClientApiModule());
            builder.RegisterModule(new Zetbox.API.Client.HttpClientModule());
            builder.RegisterModule(new Zetbox.DalProvider.Memory.MemoryProvider());
        }
Пример #2
0
        protected override void SetupBuilder(Autofac.ContainerBuilder builder)
        {
            base.SetupBuilder(builder);
            builder.RegisterModule(new Zetbox.Client.ClientModule());
            builder.RegisterModule(new Zetbox.API.Client.HttpClientModule());

            builder
                .RegisterType<ProxyMock>()
                .As<IProxy>()
                .InstancePerLifetimeScope();
        }
Пример #3
0
        protected override void SetupBuilder(Autofac.ContainerBuilder builder)
        {
            base.SetupBuilder(builder);

            builder.RegisterModule(new Zetbox.API.ApiModule());
            builder.RegisterModule(new Zetbox.API.Server.ServerApiModule());

            builder
                .RegisterType<MetaDataResolverMock>()
                .As<IMetaDataResolver>()
                .InstancePerDependency();

            builder.Register(c => new ZetboxContextMock(c.Resolve<IMetaDataResolver>(), null, c.Resolve<ZetboxConfig>(), c.Resolve<Func<IFrozenContext>>(), c.Resolve<InterfaceType.Factory>()))
                .As<IZetboxContext>()
                .As<IFrozenContext>()
                .As<IReadOnlyZetboxContext>()
                .InstancePerDependency();
        }
Пример #4
0
        protected override void Load(Autofac.ContainerBuilder builder)
        {
            base.Load(builder);

            builder
                .RegisterModule<Zetbox.API.ApiModule>();

            builder
                .RegisterType<Zetbox.API.Common.Reporting.LoggingErrorReporter>()
                .AsImplementedInterfaces()
                .SingleInstance();

            builder
                .RegisterType<CachingMetaDataResolver>()
                .As<CachingMetaDataResolver>()
                .As<IMetaDataResolver>()
                .SingleInstance();

            builder
                .RegisterType<InvocationExecutor>()
                .As<IInvocationExecutor>()
                .SingleInstance();

            builder
                .RegisterType<IconConverter>()
                .As<IIconConverter>()
                .SingleInstance();

            builder.RegisterModule<TextExtractor.Module>();

            builder
                .RegisterType<Fulltext.DataObjectFormatter>()
                .SingleInstance();

            builder
                .RegisterType<AssetsManager>()
                .As<IAssetsManager>()
                .SingleInstance();

            builder.RegisterModule<Zetbox.Objects.InterfaceModule>();
            builder.RegisterModule((Module)Activator.CreateInstance(Type.GetType("Zetbox.DalProvider.Memory.MemoryProvider, Zetbox.DalProvider.Memory", true)));
            builder.RegisterModule<Zetbox.Assets.AssetsModule>();
        }
Пример #5
0
        protected override void SetupBuilder(Autofac.ContainerBuilder builder)
        {
            base.SetupBuilder(builder);
            builder.RegisterModule(new Zetbox.API.ApiModule());
            builder.RegisterModule(new Zetbox.API.Client.ClientApiModule());
            builder.RegisterModule(new Zetbox.API.Client.HttpClientModule());
            builder.RegisterModule(new Zetbox.Client.ClientModule());
            builder.RegisterModule(new Zetbox.DalProvider.Client.ClientProvider());
            builder.RegisterModule(new Zetbox.DalProvider.Memory.MemoryProvider());
            builder.RegisterModule(new Zetbox.Objects.InterfaceModule());
            builder.RegisterModule(new Zetbox.Objects.MemoryModule());

            builder
                .RegisterType<ProxyMock>()
                .As<IProxy>()
                .InstancePerLifetimeScope();
        }
Пример #6
0
        protected override void SetupBuilder(Autofac.ContainerBuilder builder)
        {
            base.SetupBuilder(builder);

            builder.RegisterModule(new Zetbox.DalProvider.Client.ClientProvider());

            builder.RegisterType<ZetboxMockFactory>()
                .As<Zetbox.Client.Mocks.ZetboxMockFactory>()
                .InstancePerLifetimeScope();

            builder.RegisterType<TestViewModelFactory>()
                .AsSelf()
                .AsImplementedInterfaces()
                .InstancePerDependency();

            builder.RegisterType<NullIdentityResolver>()
                .AsSelf()
                .AsImplementedInterfaces()
                .InstancePerDependency();

            builder.RegisterType<TestProxy>()
                .As<IProxy>()
                .InstancePerDependency();
        }
Пример #7
0
        private static void SetupExtensibility(Autofac.ContainerBuilder builder)
        {
            var dynamicProxy = new CastleDynamicProxyProvider();
            var aopRepository = new AspectRepository(dynamicProxy);

            var dllPlugins =
                (from key in ConfigurationManager.AppSettings.AllKeys
                 where key.StartsWith("PluginsPath", StringComparison.OrdinalIgnoreCase)
                 let path = ConfigurationManager.AppSettings[key]
                 let pathRelative = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path)
                 let chosenPath = Directory.Exists(pathRelative) ? pathRelative : path
                 select chosenPath)
                .ToList();
            builder.RegisterInstance(new PluginsConfiguration { Directories = dllPlugins });

            builder.RegisterType<SystemInitialization>();
            builder.RegisterType<AutofacObjectFactory>().As<IObjectFactory>().SingleInstance();
            builder.RegisterType<AutofacMefProvider>().As<IExtensibilityProvider>().SingleInstance();
            builder.RegisterGeneric(typeof(PluginRepository<>)).As(typeof(IPluginRepository<>)).SingleInstance();

            builder.RegisterInstance(aopRepository).As<IAspectRegistrator, IAspectComposer, IInterceptorRegistrator>();
            builder.RegisterInstance(dynamicProxy).As<IMixinProvider, IDynamicProxyProvider>();

            if (ConfigurationManager.AppSettings["Revenj.AllowAspects"] == "true")
                builder.RegisterModule(new AspectsModule(aopRepository));
        }
Пример #8
0
        private static void SetupExtensibility(Autofac.ContainerBuilder builder, bool withAspects)
        {
            var dynamicProxy = new CastleDynamicProxyProvider();
            var aopRepository = new AspectRepository(dynamicProxy);

            var assemblies = Revenj.Utility.AssemblyScanner.GetAssemblies().Where(it => it.FullName.StartsWith("Revenj."));
            builder.RegisterInstance(new PluginsConfiguration { Assemblies = assemblies });

            builder.RegisterType<SystemInitialization>();
            builder.RegisterType<AutofacObjectFactory>().As<IObjectFactory>().SingleInstance();
            builder.RegisterType<AutofacMefProvider>().As<IExtensibilityProvider>().SingleInstance();
            builder.RegisterGeneric(typeof(PluginRepository<>)).As(typeof(IPluginRepository<>)).SingleInstance();

            builder.RegisterInstance(aopRepository).As<IAspectRegistrator, IAspectComposer, IInterceptorRegistrator>();
            builder.RegisterInstance(dynamicProxy).As<IMixinProvider, IDynamicProxyProvider>();

            if (withAspects)
            {
                foreach (var m in AssemblyScanner.GetAllTypes())
                {
                    if (m.IsPublic && typeof(Autofac.Module).IsAssignableFrom(m) && m.GetConstructor(new Type[0]) != null)
                        builder.RegisterModule((Autofac.Module)Activator.CreateInstance(m));
                }
                builder.RegisterModule(new AspectsModule(aopRepository));
            }
        }