PluginSkeleton.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #region Apache License
  2. //
  3. // Licensed to the Apache Software Foundation (ASF) under one or more
  4. // contributor license agreements. See the NOTICE file distributed with
  5. // this work for additional information regarding copyright ownership.
  6. // The ASF licenses this file to you under the Apache License, Version 2.0
  7. // (the "License"); you may not use this file except in compliance with
  8. // the License. You may obtain a copy of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS,
  14. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. // See the License for the specific language governing permissions and
  16. // limitations under the License.
  17. //
  18. #endregion
  19. using log4net.Repository;
  20. namespace log4net.Plugin
  21. {
  22. /// <summary>
  23. /// Base implementation of <see cref="IPlugin"/>
  24. /// </summary>
  25. /// <remarks>
  26. /// <para>
  27. /// Default abstract implementation of the <see cref="IPlugin"/>
  28. /// interface. This base class can be used by implementors
  29. /// of the <see cref="IPlugin"/> interface.
  30. /// </para>
  31. /// </remarks>
  32. /// <author>Nicko Cadell</author>
  33. /// <author>Gert Driesen</author>
  34. public abstract class PluginSkeleton : IPlugin
  35. {
  36. #region Protected Instance Constructors
  37. /// <summary>
  38. /// Constructor
  39. /// </summary>
  40. /// <param name="name">the name of the plugin</param>
  41. /// <remarks>
  42. /// Initializes a new Plugin with the specified name.
  43. /// </remarks>
  44. protected PluginSkeleton(string name)
  45. {
  46. m_name = name;
  47. }
  48. #endregion Protected Instance Constructors
  49. #region Implementation of IPlugin
  50. /// <summary>
  51. /// Gets or sets the name of the plugin.
  52. /// </summary>
  53. /// <value>
  54. /// The name of the plugin.
  55. /// </value>
  56. /// <remarks>
  57. /// <para>
  58. /// Plugins are stored in the <see cref="PluginMap"/>
  59. /// keyed by name. Each plugin instance attached to a
  60. /// repository must be a unique name.
  61. /// </para>
  62. /// <para>
  63. /// The name of the plugin must not change one the
  64. /// plugin has been attached to a repository.
  65. /// </para>
  66. /// </remarks>
  67. public virtual string Name
  68. {
  69. get { return m_name; }
  70. set { m_name = value; }
  71. }
  72. /// <summary>
  73. /// Attaches this plugin to a <see cref="ILoggerRepository"/>.
  74. /// </summary>
  75. /// <param name="repository">The <see cref="ILoggerRepository"/> that this plugin should be attached to.</param>
  76. /// <remarks>
  77. /// <para>
  78. /// A plugin may only be attached to a single repository.
  79. /// </para>
  80. /// <para>
  81. /// This method is called when the plugin is attached to the repository.
  82. /// </para>
  83. /// </remarks>
  84. public virtual void Attach(ILoggerRepository repository)
  85. {
  86. m_repository = repository;
  87. }
  88. /// <summary>
  89. /// Is called when the plugin is to shutdown.
  90. /// </summary>
  91. /// <remarks>
  92. /// <para>
  93. /// This method is called to notify the plugin that
  94. /// it should stop operating and should detach from
  95. /// the repository.
  96. /// </para>
  97. /// </remarks>
  98. public virtual void Shutdown()
  99. {
  100. }
  101. #endregion Implementation of IPlugin
  102. #region Protected Instance Properties
  103. /// <summary>
  104. /// The repository for this plugin
  105. /// </summary>
  106. /// <value>
  107. /// The <see cref="ILoggerRepository" /> that this plugin is attached to.
  108. /// </value>
  109. /// <remarks>
  110. /// <para>
  111. /// Gets or sets the <see cref="ILoggerRepository" /> that this plugin is
  112. /// attached to.
  113. /// </para>
  114. /// </remarks>
  115. protected virtual ILoggerRepository LoggerRepository
  116. {
  117. get { return this.m_repository; }
  118. set { this.m_repository = value; }
  119. }
  120. #endregion Protected Instance Properties
  121. #region Private Instance Fields
  122. /// <summary>
  123. /// The name of this plugin.
  124. /// </summary>
  125. private string m_name;
  126. /// <summary>
  127. /// The repository this plugin is attached to.
  128. /// </summary>
  129. private ILoggerRepository m_repository;
  130. #endregion Private Instance Fields
  131. }
  132. }