Пример #1
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);
            }
        }
Пример #2
0
        public static SettingProvider GetProvider(Tiandao.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 SettingProvider(plugin, configuration);
            }));
        }
Пример #3
0
        private void Loader_PluginLoaded(object sender, PluginLoadedEventArgs e)
        {
            var proxy = new ConfigurationProxy(() => OptionUtility.GetConfiguration(e.Plugin));

            e.Plugin.Context.ApplicationContext.OptionManager.Providers.Add(proxy);
        }