Ejemplo n.º 1
0
 private void Loader_PluginLoaded(object sender, PluginLoadedEventArgs e)
 {
     if (OptionUtility.HasConfigurationFile(e.Plugin))
     {
         var proxy = new ConfigurationProxy(() => OptionUtility.GetConfiguration(e.Plugin));
         e.Plugin.Context.ApplicationContext.OptionManager.Providers.Add(proxy);
     }
 }
Ejemplo n.º 2
0
        private void Loader_PluginUnloaded(object sender, PluginUnloadedEventArgs e)
        {
            var providers = e.Plugin.Context.ApplicationContext.OptionManager.Providers;

            var found = providers.FirstOrDefault(provider =>
            {
                var proxy = provider as ConfigurationProxy;

                return(proxy != null && proxy.IsValueCreated &&
                       string.Equals(proxy.Value.FilePath, OptionUtility.GetConfigurationFilePath(e.Plugin)));
            });

            if (found != null)
            {
                providers.Remove(found);
            }
        }
Ejemplo n.º 3
0
        public static PluginSettingsProvider GetProvider(Zongsoft.Plugins.Plugin plugin)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }

            var configuration = OptionUtility.GetConfiguration(plugin);

            if (configuration == null)
            {
                return(null);
            }

            return(_cache.Get(plugin.FilePath, key =>
            {
                return new PluginSettingsProvider(plugin, configuration);
            }));
        }