Log4NetConfigurationSectionHandler.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // .NET Compact Framework 1.0 has no support for application .config files
  20. #if !NETCF
  21. using System.Configuration;
  22. using System.Xml;
  23. namespace log4net.Config
  24. {
  25. /// <summary>
  26. /// Class to register for the log4net section of the configuration file
  27. /// </summary>
  28. /// <remarks>
  29. /// The log4net section of the configuration file needs to have a section
  30. /// handler registered. This is the section handler used. It simply returns
  31. /// the XML element that is the root of the section.
  32. /// </remarks>
  33. /// <example>
  34. /// Example of registering the log4net section handler :
  35. /// <code lang="XML" escaped="true">
  36. /// <configuration>
  37. /// <configSections>
  38. /// <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  39. /// </configSections>
  40. /// <log4net>
  41. /// log4net configuration XML goes here
  42. /// </log4net>
  43. /// </configuration>
  44. /// </code>
  45. /// </example>
  46. /// <author>Nicko Cadell</author>
  47. /// <author>Gert Driesen</author>
  48. public class Log4NetConfigurationSectionHandler : IConfigurationSectionHandler
  49. {
  50. #region Public Instance Constructors
  51. /// <summary>
  52. /// Initializes a new instance of the <see cref="Log4NetConfigurationSectionHandler"/> class.
  53. /// </summary>
  54. /// <remarks>
  55. /// <para>
  56. /// Default constructor.
  57. /// </para>
  58. /// </remarks>
  59. public Log4NetConfigurationSectionHandler()
  60. {
  61. }
  62. #endregion Public Instance Constructors
  63. #region Implementation of IConfigurationSectionHandler
  64. /// <summary>
  65. /// Parses the configuration section.
  66. /// </summary>
  67. /// <param name="parent">The configuration settings in a corresponding parent configuration section.</param>
  68. /// <param name="configContext">The configuration context when called from the ASP.NET configuration system. Otherwise, this parameter is reserved and is a null reference.</param>
  69. /// <param name="section">The <see cref="XmlNode" /> for the log4net section.</param>
  70. /// <returns>The <see cref="XmlNode" /> for the log4net section.</returns>
  71. /// <remarks>
  72. /// <para>
  73. /// Returns the <see cref="XmlNode"/> containing the configuration data,
  74. /// </para>
  75. /// </remarks>
  76. public object Create(object parent, object configContext, XmlNode section)
  77. {
  78. return section;
  79. }
  80. #endregion Implementation of IConfigurationSectionHandler
  81. }
  82. }
  83. #endif // !NETCF