The Labs \ Source Viewer \ SSCLI \ System.ComponentModel \ AttributeProviderAttribute

  1. //------------------------------------------------------------------------------
  2. // <copyright file="AttributeProviderAttribute.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.ComponentModel
  16. {
  17.    
  18.     using System;
  19.     using System.Security.Permissions;
  20.    
  21.     /// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute"]/*' />
  22.     /// <devdoc>
  23.     /// </devdoc>
  24.     [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
  25.     [AttributeUsage(AttributeTargets.Property)]
  26.     public class AttributeProviderAttribute : Attribute
  27.     {
  28.         private string _typeName;
  29.         private string _propertyName;
  30.        
  31.         /// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute.AttributeProviderAttribute"]/*' />
  32.         /// <devdoc>
  33.         /// Creates a new AttributeProviderAttribute object.
  34.         /// </devdoc>
  35.         public AttributeProviderAttribute(string typeName)
  36.         {
  37.             if (typeName == null) {
  38.                 throw new ArgumentNullException("typeName");
  39.             }
  40.            
  41.             _typeName = typeName;
  42.         }
  43.        
  44.         /// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute.AttributeProviderAttribute"]/*' />
  45.         /// <devdoc>
  46.         /// Creates a new AttributeProviderAttribute object.
  47.         /// </devdoc>
  48.         public AttributeProviderAttribute(string typeName, string propertyName)
  49.         {
  50.             if (typeName == null) {
  51.                 throw new ArgumentNullException("typeName");
  52.             }
  53.             if (propertyName == null) {
  54.                 throw new ArgumentNullException("propertyName");
  55.             }
  56.            
  57.             _typeName = typeName;
  58.             _propertyName = propertyName;
  59.         }
  60.        
  61.         /// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute.AttributeProviderAttribute1"]/*' />
  62.         /// <devdoc>
  63.         /// Creates a new AttributeProviderAttribute object.
  64.         /// </devdoc>
  65.         public AttributeProviderAttribute(Type type)
  66.         {
  67.             if (type == null) {
  68.                 throw new ArgumentNullException("type");
  69.             }
  70.            
  71.             _typeName = type.AssemblyQualifiedName;
  72.         }
  73.        
  74.         /// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute.TypeName"]/*' />
  75.         /// <devdoc>
  76.         /// The TypeName property returns the assembly qualified type name
  77.         /// passed into the constructor.
  78.         /// </devdoc>
  79.         public string TypeName {
  80.             get { return _typeName; }
  81.         }
  82.        
  83.         /// <include file='doc\AttributeProviderAttribute.uex' path='docs/doc[@for="AttributeProviderAttribute.TypeName"]/*' />
  84.         /// <devdoc>
  85.         /// The TypeName property returns the property name that will be used to query attributes from.
  86.         /// </devdoc>
  87.         public string PropertyName {
  88.             get { return _propertyName; }
  89.         }
  90.     }
  91. }

Developer Fusion