Example #1
0
        /// <summary>
        /// Gets the service.
        /// </summary>
        /// <param name="serviceType">The service type.</param>
        /// <returns>An object.</returns>
        public object GetService(Type serviceType)
        {
            var plugins = this.pluginManagers.GetPlugins();

            if (plugins.Count != pluginCount)
            {
                pluginCount = plugins.Count;
                pluginServiceTypeCache.InitCache();
                rootProvider = PopuPluginService();
            }
            var plugin = pluginServiceTypeCache.GetTypeOfPlugin(serviceType);

            if (plugin == null)
            {
                var obj = rootProvider.GetService(serviceType);
                ReplaceSingleImp(serviceType, obj);
                return(obj);
            }

            var process = new ResolveProcess(plugin, pluginServiceTypeCache);

            lock (GlobLock.LockObj)
            {
                aspectConfiguration.ResolveCall = process.ResolveType;
                var obj = rootProvider.GetService(serviceType);
                ReplaceSingleImp(serviceType, obj);
                aspectConfiguration.ResolveCall = null;
                return(obj);
            }
        }
Example #2
0
        /// <summary>
        /// Resolves the type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>A bool.</returns>
        public bool ResolveType(Type type)
        {
            var t_p = pluginAssemblyCache.GetTypeOfPlugin(type);

            if (t_p == null)
            {
                return(true);
            }
            return(plugins.AuthKey.Any(t => t == t_p.Key) || plugins.Key == t_p.Key);
        }
Example #3
0
        /// <summary>
        /// Gets the service.
        /// </summary>
        /// <param name="serviceType">The service type.</param>
        /// <returns>An object.</returns>
        public object GetService(Type serviceType)
        {
            var plugin = cache.GetTypeOfPlugin(serviceType);

            if (plugin == null)
            {
                return(serviceProvider.GetService(serviceType));
            }

            var process = new ResolveProcess(plugin, cache);

            lock (GlobLock.LockObj)
            {
                aspectConfiguration.ResolveCall = process.ResolveType;
                var obj = serviceProvider.GetService(serviceType);
                aspectConfiguration.ResolveCall = null;
                return(obj);
            }
        }