123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- #region Apache License
- #endregion
- using System;
- using System.Collections;
- using log4net.Util;
- using log4net.Repository;
- namespace log4net.Plugin
- {
-
-
-
-
-
-
-
-
-
-
-
- public sealed class PluginMap
- {
- #region Public Instance Constructors
-
-
-
-
-
-
-
-
-
-
- public PluginMap(ILoggerRepository repository)
- {
- m_repository = repository;
- }
- #endregion Public Instance Constructors
- #region Public Instance Properties
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public IPlugin this[string name]
- {
- get
- {
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
- lock(this)
- {
- return (IPlugin)m_mapName2Plugin[name];
- }
- }
- }
-
-
-
-
-
-
-
-
-
- public PluginCollection AllPlugins
- {
- get
- {
- lock(this)
- {
- return new PluginCollection(m_mapName2Plugin.Values);
- }
- }
- }
-
- #endregion Public Instance Properties
- #region Public Instance Methods
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public void Add(IPlugin plugin)
- {
- if (plugin == null)
- {
- throw new ArgumentNullException("plugin");
- }
- IPlugin curPlugin = null;
- lock(this)
- {
-
- curPlugin = m_mapName2Plugin[plugin.Name] as IPlugin;
-
- m_mapName2Plugin[plugin.Name] = plugin;
- }
-
- if (curPlugin != null)
- {
- curPlugin.Shutdown();
- }
-
- plugin.Attach(m_repository);
- }
-
-
-
-
-
-
-
-
-
- public void Remove(IPlugin plugin)
- {
- if (plugin == null)
- {
- throw new ArgumentNullException("plugin");
- }
- lock(this)
- {
- m_mapName2Plugin.Remove(plugin.Name);
- }
- }
- #endregion Public Instance Methods
- #region Private Instance Fields
- private readonly Hashtable m_mapName2Plugin = new Hashtable();
- private readonly ILoggerRepository m_repository;
- #endregion Private Instance Fields
- }
- }
|