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