Exemple #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);
            }
        }
        /// <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);
            }
        }