RepositoryAttribute.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 reading assembly attributes
  20. #if !NETCF
  21. using System;
  22. namespace log4net.Config
  23. {
  24. /// <summary>
  25. /// Assembly level attribute that specifies the logging repository for the assembly.
  26. /// </summary>
  27. /// <remarks>
  28. /// <para>
  29. /// Assemblies are mapped to logging repository. This attribute specified
  30. /// on the assembly controls
  31. /// the configuration of the repository. The <see cref="Name"/> property specifies the name
  32. /// of the repository that this assembly is a part of. The <see cref="RepositoryType"/>
  33. /// specifies the type of the <see cref="log4net.Repository.ILoggerRepository"/> object
  34. /// to create for the assembly. If this attribute is not specified or a <see cref="Name"/>
  35. /// is not specified then the assembly will be part of the default shared logging repository.
  36. /// </para>
  37. /// <para>
  38. /// This attribute can only be specified on the assembly and may only be used
  39. /// once per assembly.
  40. /// </para>
  41. /// </remarks>
  42. /// <author>Nicko Cadell</author>
  43. /// <author>Gert Driesen</author>
  44. [AttributeUsage(AttributeTargets.Assembly)]
  45. [Serializable]
  46. public /*sealed*/ class RepositoryAttribute : Attribute
  47. {
  48. //
  49. // Class is not sealed because DomainAttribute extends it while it is obsoleted
  50. //
  51. #region Public Instance Constructors
  52. /// <summary>
  53. /// Initializes a new instance of the <see cref="RepositoryAttribute" /> class.
  54. /// </summary>
  55. /// <remarks>
  56. /// <para>
  57. /// Default constructor.
  58. /// </para>
  59. /// </remarks>
  60. public RepositoryAttribute()
  61. {
  62. }
  63. /// <summary>
  64. /// Initialize a new instance of the <see cref="RepositoryAttribute" /> class
  65. /// with the name of the repository.
  66. /// </summary>
  67. /// <param name="name">The name of the repository.</param>
  68. /// <remarks>
  69. /// <para>
  70. /// Initialize the attribute with the name for the assembly's repository.
  71. /// </para>
  72. /// </remarks>
  73. public RepositoryAttribute(string name)
  74. {
  75. m_name = name;
  76. }
  77. #endregion Public Instance Constructors
  78. #region Public Instance Properties
  79. /// <summary>
  80. /// Gets or sets the name of the logging repository.
  81. /// </summary>
  82. /// <value>
  83. /// The string name to use as the name of the repository associated with this
  84. /// assembly.
  85. /// </value>
  86. /// <remarks>
  87. /// <para>
  88. /// This value does not have to be unique. Several assemblies can share the
  89. /// same repository. They will share the logging configuration of the repository.
  90. /// </para>
  91. /// </remarks>
  92. public string Name
  93. {
  94. get { return m_name; }
  95. set { m_name = value ; }
  96. }
  97. /// <summary>
  98. /// Gets or sets the type of repository to create for this assembly.
  99. /// </summary>
  100. /// <value>
  101. /// The type of repository to create for this assembly.
  102. /// </value>
  103. /// <remarks>
  104. /// <para>
  105. /// The type of the repository to create for the assembly.
  106. /// The type must implement the <see cref="log4net.Repository.ILoggerRepository"/>
  107. /// interface.
  108. /// </para>
  109. /// <para>
  110. /// This will be the type of repository created when
  111. /// the repository is created. If multiple assemblies reference the
  112. /// same repository then the repository is only created once using the
  113. /// <see cref="RepositoryType" /> of the first assembly to call into the
  114. /// repository.
  115. /// </para>
  116. /// </remarks>
  117. public Type RepositoryType
  118. {
  119. get { return m_repositoryType; }
  120. set { m_repositoryType = value ; }
  121. }
  122. #endregion Public Instance Properties
  123. #region Private Instance Fields
  124. private string m_name = null;
  125. private Type m_repositoryType = null;
  126. #endregion Private Instance Fields
  127. }
  128. }
  129. #endif // !NETCF