Example #1
0
            public DryIocContainerBuilder(
                IEnumerable <Assembly> pluginAssemblies,
                IEnumerable <string> pluginPaths,
                bool dslAspects = false)
            {
                this.DslAspects = dslAspects;
                var container = new DryIoc.Container(rules => rules.With(FactoryMethod.ConstructorWithResolvableArguments)).OpenScopeWithoutContext();

                Proxy = new CastleDynamicProxyProvider();
                this.RegisterSingleton <IMixinProvider>(Proxy);
                this.RegisterSingleton <IDynamicProxyProvider>(Proxy);
                var aopRepository = new AspectRepository(Proxy);

                this.RegisterSingleton <IAspectRegistrator>(aopRepository);
                this.RegisterSingleton <IAspectComposer>(aopRepository);
                this.RegisterSingleton <IInterceptorRegistrator>(aopRepository);
                Factory = new DryIocObjectFactory(container, aopRepository);
                this.RegisterSingleton <IObjectFactory>(Factory);
                this.RegisterSingleton <IServiceProvider>(Factory);
                Plugins = new PluginsConfiguration
                {
                    Directories = (pluginPaths ?? new string[0]).ToList(),
                    Assemblies  = (pluginAssemblies ?? new Assembly[0]).ToList()
                };
                this.RegisterSingleton(Plugins);
                this.RegisterType <SystemInitialization>();
                this.RegisterType(typeof(PluginRepository <>), InstanceScope.Singleton, true, typeof(IPluginRepository <>));
                var types = AssemblyScanner.GetAllTypes();

                this.RegisterSingleton <IExtensibilityProvider>(new DryIocMefProvider(Plugins, Proxy, container));
                DryIocObjectFactory.RegisterToContainer(container, this);
            }
Example #2
0
            public AspectsModule(AspectRepository repository)
            {
                this.Repository = repository;
                //FIX for Castle interception issue
#if !NETSTANDARD2_0
                Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(typeof(ServiceContractAttribute));
#endif
            }
Example #3
0
        private AspectRepository(AspectRepository parentRepository)
        {
            Contract.Requires(parentRepository != null);

            this.ParentRepository     = parentRepository;
            this.DynamicProxyProvider = parentRepository.DynamicProxyProvider;
            RequireInitialization     = true;
        }
Example #4
0
            public AutofacContainerBuilder(
                IEnumerable <Assembly> pluginAssemblies,
                IEnumerable <string> pluginPaths,
                bool loadModules,
                bool withAspects,
                bool dslAspects)
            {
                this.Builder    = new ContainerBuilder();
                this.DslAspects = dslAspects;
                Builder.RegisterType <AutofacObjectFactory, IObjectFactory, IServiceProvider>(InstanceScope.Singleton);
                Builder.RegisterType <AutofacMefProvider, IExtensibilityProvider>(InstanceScope.Singleton);
                var dynamicProxy = new CastleDynamicProxyProvider();

                Builder.RegisterSingleton <IMixinProvider>(dynamicProxy);
                Builder.RegisterSingleton <IDynamicProxyProvider>(dynamicProxy);
                var aopRepository = new AspectRepository(dynamicProxy);

                Builder.RegisterSingleton <IAspectRegistrator>(aopRepository);
                Builder.RegisterSingleton <IAspectComposer>(aopRepository);
                Builder.RegisterSingleton <IInterceptorRegistrator>(aopRepository);
                Builder.RegisterSingleton(new PluginsConfiguration
                {
                    Directories = (pluginPaths ?? new string[0]).ToList(),
                    Assemblies  = (pluginAssemblies ?? new Assembly[0]).ToList()
                });
                Builder.RegisterType <SystemInitialization>();
                Builder.RegisterType(typeof(PluginRepository <>), InstanceScope.Singleton, true, typeof(IPluginRepository <>));
                if (withAspects)
                {
                    Builder.RegisterModule(new AspectsModule(aopRepository));
                }
                if (loadModules)
                {
                    var types = AssemblyScanner.GetAllTypes();
                    foreach (var m in types)
                    {
                        if (m.Assembly.FullName.StartsWith("Revenj."))
                        {
                            continue;
                        }
                        if (m.IsPublic && !m.IsAbstract && typeof(Revenj.Extensibility.Autofac.Module).IsAssignableFrom(m) && m.GetConstructor(new Type[0]) != null)
                        {
                            Builder.RegisterModule((Revenj.Extensibility.Autofac.Module)Activator.CreateInstance(m));
                        }
                    }
                }
            }