1 // -----------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 // -----------------------------------------------------------------------
5 using System
.ComponentModel
.Composition
.Hosting
;
6 using System
.Diagnostics
.CodeAnalysis
;
8 namespace System
.ComponentModel
.Composition
11 /// Specifies that a type, property, field, or method provides a particular export.
13 [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
14 [AttributeUsage(AttributeTargets
.Class
| AttributeTargets
.Field
| AttributeTargets
.Property
| AttributeTargets
.Method
,
15 AllowMultiple
= true, Inherited
= false)]
16 public class ExportAttribute
: Attribute
19 /// Initializes a new instance of the <see cref="ExportAttribute"/> class, exporting the
20 /// type or member marked with this attribute under the default contract name.
24 /// The default contract name is the result of calling
25 /// <see cref="AttributedModelServices.GetContractName(Type)"/> on the type of the
26 /// property or field, or the type itself, that is marked with this attribute.
29 /// The contract name is compared using a case-sensitive, non-linguistic comparison
30 /// using <see cref="StringComparer.Ordinal"/>.
33 public ExportAttribute()
34 : this((string)null, (Type
)null)
39 /// Initializes a new instance of the <see cref="ExportAttribute"/> class, exporting the
40 /// type or member marked with this attribute under a contract name derived from the
43 /// <param name="contractType">
44 /// A <see cref="Type"/> of which to derive the contract name to export the type or
45 /// member marked with this attribute, under; or <see langword="null"/> to use the
46 /// default contract name.
50 /// The contract name is the result of calling
51 /// <see cref="AttributedModelServices.GetContractName(Type)"/> on
52 /// <paramref name="contractType"/>.
55 /// The default contract name is the result of calling
56 /// <see cref="AttributedModelServices.GetContractName(Type)"/> on the type of the
57 /// property or field, or the type itself, that is marked with this attribute.
60 /// The contract name is compared using a case-sensitive, non-linguistic comparison
61 /// using <see cref="StringComparer.Ordinal"/>.
64 public ExportAttribute(Type contractType
)
65 : this((string)null, contractType
)
70 /// Initializes a new instance of the <see cref="ExportAttribute"/> class, exporting the
71 /// type or member marked with this attribute under the specified contract name.
73 /// <param name="contractName">
74 /// A <see cref="String"/> containing the contract name to export the type or member
75 /// marked with this attribute, under; or <see langword="null"/> or an empty string
76 /// ("") to use the default contract name.
80 /// The default contract name is the result of calling
81 /// <see cref="AttributedModelServices.GetContractName(Type)"/> on the property or field
82 /// type, or the type itself that this is marked with this attribute.
85 /// The contract name is compared using a case-sensitive, non-linguistic comparison
86 /// using <see cref="StringComparer.Ordinal"/>.
89 public ExportAttribute(string contractName
)
90 : this(contractName
, (Type
)null)
95 /// Initializes a new instance of the <see cref="ExportAttribute"/> class, exporting the
96 /// type or member marked with this attribute under the specified contract name.
98 /// <param name="contractName">
99 /// A <see cref="String"/> containing the contract name to export the type or member
100 /// marked with this attribute, under; or <see langword="null"/> or an empty string
101 /// ("") to use the default contract name.
103 /// <param name="contractType">
104 /// A <see cref="Type"/> of which to derive the contract name to export the type or
105 /// member marked with this attribute, under; or <see langword="null"/> to use the
106 /// default contract name.
110 /// The default contract name is the result of calling
111 /// <see cref="AttributedModelServices.GetContractName(Type)"/> on the property or field
112 /// type, or the type itself that this is marked with this attribute.
115 /// The contract name is compared using a case-sensitive, non-linguistic comparison
116 /// using <see cref="StringComparer.Ordinal"/>.
119 public ExportAttribute(string contractName
, Type contractType
)
121 this.ContractName
= contractName
;
122 this.ContractType
= contractType
;
126 /// Gets the contract name to export the type or member under.
129 /// A <see cref="String"/> containing the contract name to export the type or member
130 /// marked with this attribute, under. The default value is an empty string ("").
132 public string ContractName { get; private set; }
135 /// Get the contract type that is exported by the member that this attribute is attached to.
138 /// A <see cref="Type"/> of the export that is be provided. The default value is
139 /// <see langword="null"/> which means that the type will be obtained by looking at the type on
140 /// the member that this export is attached to.
142 public Type ContractType { get; private set; }