示例#1
0
        private static void SetupExtensibility(IRegistry registry)
        {
            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();
            registry.RegisterInstance(new PluginsConfiguration { Directories = dllPlugins });

            registry.Register<SystemInitialization>();
            registry.Register<IObjectFactory, DryIocObjectFactory>(Reuse.Singleton);
            registry.Register<IExtensibilityProvider, DryIocMefProvider>(Reuse.Singleton);
            registry.Register(typeof(IPluginRepository<>), typeof(PluginRepository<>), Reuse.Singleton);

            registry.RegisterInstance<IAspectRegistrator>(aopRepository);
            registry.RegisterInstance<IAspectComposer>(aopRepository);
            //registry.RegisterInstance<IInterceptorRegistrator>(aopRepository);
            registry.RegisterInstance<IMixinProvider>(dynamicProxy);
            registry.RegisterInstance<IDynamicProxyProvider>(dynamicProxy);
        }
示例#2
0
        private static void SetupExtensibility(IRegistry registry)
        {
            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();

            registry.RegisterInstance(new PluginsConfiguration {
                Directories = dllPlugins
            });

            registry.Register <SystemInitialization>();
            registry.Register <IObjectFactory, DryIocObjectFactory>(Reuse.Singleton);
            registry.Register <IExtensibilityProvider, DryIocMefProvider>(Reuse.Singleton);
            registry.Register(typeof(IPluginRepository <>), typeof(PluginRepository <>), Reuse.Singleton);

            registry.RegisterInstance <IAspectRegistrator>(aopRepository);
            registry.RegisterInstance <IAspectComposer>(aopRepository);
            //registry.RegisterInstance<IInterceptorRegistrator>(aopRepository);
            registry.RegisterInstance <IMixinProvider>(dynamicProxy);
            registry.RegisterInstance <IDynamicProxyProvider>(dynamicProxy);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        public static void Clear()
        {
            aspectRepository = new AspectRepository();
            aspectMatcher    = new AspectMatcher();

            jointPointRegisterCheckTable.Clear();
        }
示例#4
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));
            }
        }
示例#5
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));
            }
        }
示例#6
0
        private static void SetupExtensibility(Revenj.Extensibility.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));
        }
示例#7
0
        private static void SetupExtensibility(Autofac.ContainerBuilder builder, bool withAspects)
        {
            var dynamicProxy  = new CastleDynamicProxyProvider();
            var aopRepository = new AspectRepository(dynamicProxy);

            var assemblies = NGS.Utility.AssemblyScanner.GetAssemblies().Where(it => it.FullName.StartsWith("NGS."));

            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)
            {
                var autofacModules =
                    from type in NGS.Utility.AssemblyScanner.GetAllTypes()
                    where type.IsPublic && typeof(Autofac.Module).IsAssignableFrom(type) && type.GetConstructor(new Type[0]) != null
                    select type;
                foreach (var m in autofacModules)
                {
                    builder.RegisterModule((Autofac.Module)Activator.CreateInstance(m));
                }
                builder.RegisterModule(new AspectsModule(aopRepository));
            }
        }
        private static void CreateAspects(ApplicationContext AppContext)
        {
            AspectRepository repo = new AspectRepository(AppContext);

            {
                List <Aspect> list = GetAspectList();
                repo.InsertAll(list);
            }
        }
示例#9
0
        private static void SetupExtensibility(Autofac.ContainerBuilder builder)
        {
            var dynamicProxy = new CastleDynamicProxyProvider();
            var aopRepository = new AspectRepository(dynamicProxy);

            var assemblies = NGS.Utility.AssemblyScanner.GetAssemblies().Where(it => it.FullName.StartsWith("NGS."));
            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>();
        }
        private static void SetupExtensibility(Revenj.Extensibility.Autofac.ContainerBuilder builder, bool withAspects, bool externalConfiguration)
        {
            var dynamicProxy = new CastleDynamicProxyProvider();
            var aopRepository = new AspectRepository(dynamicProxy);

            var dllPlugins = externalConfiguration == false ? new string[0] :
                (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)
                .ToArray();

            var assemblies = Revenj.Utility.AssemblyScanner.GetAssemblies().Where(it => it.FullName.StartsWith("Revenj."));
            builder.RegisterInstance(new PluginsConfiguration { Assemblies = assemblies, 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>();

            var types = AssemblyScanner.GetAllTypes();//TODO: force load everything
            if (withAspects)
            {
                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));
                }
                builder.RegisterModule(new AspectsModule(aopRepository));
            }
        }
示例#11
0
 public AspectsModule(AspectRepository repository)
 {
     this.Repository = repository;
 }
示例#12
0
 public AspectsModule(AspectRepository repository)
 {
     this.Repository = repository;
     //FIX for Castle interception issue
     Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(typeof(ServiceContractAttribute));
 }
示例#13
0
 public AspectsModule(AspectRepository repository)
 {
     this.Repository = repository;
 }