Esempio n. 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);
            }
Esempio n. 2
0
 private DryIocObjectFactory(
     DryIocObjectFactory parentFactory,
     IAspectComposer aspects,
     Action cleanup)
     : this(parentFactory.CurrentScope, aspects)
 {
     this.ParentFactory = parentFactory;
     this.Cleanup = cleanup;
 }
Esempio n. 3
0
 private DryIocObjectFactory(
     DryIocObjectFactory parentFactory,
     IAspectComposer aspects,
     Action cleanup)
     : this(parentFactory.CurrentScope.OpenScopeWithoutContext(), aspects)
 {
     this.ParentFactory = parentFactory;
     this.Cleanup       = cleanup;
 }
Esempio n. 4
0
 public IObjectFactory CreateScope(string id)
 {
     BuildScopeIfRequired();
     var innerComposer = Aspects.CreateInnerComposer();
     DryIocObjectFactory tv;
     Action cleanup = string.IsNullOrEmpty(id) ? (Action)null : () => TaggedScopes.TryRemove(id, out tv);
     var factory = new DryIocObjectFactory(this, innerComposer, cleanup);
     factory.RegisterInstance<IObjectFactory>(factory);
     factory.RegisterInterfaces(innerComposer);
     if (!string.IsNullOrEmpty(id))
         TaggedScopes.TryAdd(id, factory);
     return factory;
 }
Esempio n. 5
0
        public IObjectFactory CreateScope(string id)
        {
            UpdateScopeIfRequired();
            var innerComposer = Aspects.CreateInnerComposer();
            DryIocObjectFactory tv;
            Action cleanup = string.IsNullOrEmpty(id) ? (Action)null : () => TaggedScopes.TryRemove(id, out tv);
            var    factory = new DryIocObjectFactory(this, innerComposer, cleanup);

            factory.RegisterInstance <IObjectFactory>(factory);
            factory.RegisterInstance <IServiceProvider>(factory);
            factory.RegisterInterfaces(innerComposer);
            if (!string.IsNullOrEmpty(id))
            {
                TaggedScopes.TryAdd(id, factory);
            }
            return(factory);
        }