コード例 #1
0
 public static void AddControllerType(string plugin, string controllerName, Type controllerType)
 {
     using (var locker = _controllerTypes.Lock())
     {
         locker[GetKey(plugin, controllerName)] = controllerType;
     }
 }
コード例 #2
0
        /// <summary>
        /// 获取插件的配置。
        /// </summary>
        /// <param name="bundle">插件。</param>
        /// <returns>插件的配置对象。</returns>
        private Configuration Get(IBundle bundle)
        {
            AssureConfigFileExist(bundle);              // 确保文件存在

            using (var locker = _configurations.Lock()) // 从缓存中获取
            {
                if (locker.ContainsKey(bundle))
                {
                    return(locker[bundle]);
                }
            }

            var configFile = Path.Combine(bundle.Location, ConfigurationFile);

            try
            {
                // 获取配置对象
                var configMap = new ExeConfigurationFileMap();
                configMap.ExeConfigFilename = configFile;
                var bundleConfiguration = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
                using (var locker = _configurations.Lock()) // 保存到缓存
                {
                    locker[bundle] = bundleConfiguration;
                }
                return(bundleConfiguration);
            }
            catch (ConfigurationErrorsException ex)
            {
                FileLogUtility.Error(string.Format("Failed to load the Bundle configuration file '{0}' for bundle '{1}'.", configFile, bundle.SymbolicName));
                FileLogUtility.Error(ex);
                throw;
            }
        }
コード例 #3
0
 private void AddViewEngine(IBundle bundle)
 {
     using (var locker = _viewEngines.Lock())
     {
         locker[bundle.SymbolicName] = BundleViewEngineFactory.CreateViewEngine(bundle);
     }
 }
コード例 #4
0
ファイル: InProcMessageBus.cs プロジェクト: rveluthattil/osgi
 public void Publish(Type messageType, object message)
 {
     _container.Lock(value =>
     {
         ThreadSafeList <MessageBusHandler> handlers;
         if (value.TryGetValue(messageType, out handlers))
         {
             foreach (MessageBusHandler item in handlers.ToArray())
             {
                 item(this, message);
             }
         }
     });
 }
コード例 #5
0
 public INavigationService CreateNavigationService(string extensionPoint)
 {
     using (var locker = _serviceCache.Lock())
     {
         if (!locker.ContainsKey(extensionPoint))
         {
             locker[extensionPoint] = new NavigationServiceImpl(_context, extensionPoint);
         }
         return(locker[extensionPoint]);
     }
 }