예제 #1
0
        private void SetupPluginAggregator()
        {
            if (!LoadPlugins)
            {
                return;
            }

            var settings = System.Configuration.ConfigurationManager.AppSettings;
            var configs  = settings
                           .AllKeys
                           .Where(k => k.Contains(':'))                          //Ignore keys that don't have a colon to indicate which plugin they go to
                           .Select(k => Tuple.Create(k.Split(':'), settings[k])) //Get the data -- split the key to get the plugin name and setting name, look up the key to get the value
                           .GroupBy(t => t.Item1[0])                             //Group the settings based on which plugin they're for
                           .ToDictionary(
                group => group.Key,                                              //Index the outer dictionary based on plugin
                group => group.ToDictionary(
                    t => t.Item1[1],                                             //Index the inner dictionary based on setting name
                    t => t.Item2                                                 //The actual value of the setting
                    )
                );

            PluginAggregator = new MEF.PluginAggregator(configs, new Utilities.PluginLogger(), PluginBlacklist);
            FirstChanceExceptionHandler.IgnoreModules(PluginAggregator.Select(p => p.PluginModule));
            PluginAggregator.Init();
        }
 private void SetupPluginAggregator()
 {
     var settings = System.Configuration.ConfigurationManager.AppSettings;
     var configs = settings
         .AllKeys
         .Where(k => k.Contains(':'))                            //Ignore keys that don't have a colon to indicate which plugin they go to
         .Select(k => Tuple.Create(k.Split(':'), settings[k]))   //Get the data -- split the key to get the plugin name and setting name, look up the key to get the value
         .GroupBy(t => t.Item1[0])                               //Group the settings based on which plugin they're for
         .ToDictionary(
             group => group.Key,                                 //Index the outer dictionary based on plugin
             group => group.ToDictionary(
                 t => t.Item1[1],                                //Index the inner dictionary based on setting name
                 t => t.Item2                                    //The actual value of the setting
             )
         );
     PluginAggregator = new MEF.PluginAggregator(configs, new Utilities.PluginLogger());
 }