2
// NodeAttributeAttribute.cs
7
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining
10
// a copy of this software and associated documentation files (the
11
// "Software"), to deal in the Software without restriction, including
12
// without limitation the rights to use, copy, modify, merge, publish,
13
// distribute, sublicense, and/or sell copies of the Software, and to
14
// permit persons to whom the Software is furnished to do so, subject to
15
// the following conditions:
17
// The above copyright notice and this permission notice shall be
18
// included in all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
/// Indicates that a field or property is bound to a node attribute
37
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple=true)]
38
public class NodeAttributeAttribute: Attribute
48
/// Initializes a new instance
50
public NodeAttributeAttribute ()
55
/// Initializes a new instance
57
/// <param name="name">
58
/// XML name of the attribute.
60
public NodeAttributeAttribute (string name)
61
:this (name, false, null)
66
/// Initializes a new instance
68
/// <param name="name">
69
/// XML name of the attribute.
71
/// <param name="description">
72
/// Description of the attribute.
74
public NodeAttributeAttribute (string name, string description)
75
:this (name, false, description)
80
/// Initializes a new instance
82
/// <param name="name">
83
/// XML name of the attribute.
85
/// <param name="required">
86
/// Indicates whether the attribute is required or not.
88
public NodeAttributeAttribute (string name, bool required)
89
: this (name, required, null)
94
/// Initializes a new instance
96
/// <param name="name">
97
/// XML name of the attribute.
99
/// <param name="required">
100
/// Indicates whether the attribute is required or not.
102
/// <param name="description">
103
/// Description of the attribute.
105
public NodeAttributeAttribute (string name, bool required, string description)
108
this.required = required;
109
this.description = description;
113
/// Initializes a new instance
115
/// <param name="name">
116
/// XML name of the attribute.
118
/// <param name="type">
119
/// Type of the extension node attribute.
122
/// The type of the attribute is only required when applying this attribute at class level.
123
/// It is not required when it is applied to a field, since the attribute type will be the type of the field.
125
public NodeAttributeAttribute (string name, Type type)
126
: this (name, type, false, null)
131
/// Initializes a new instance
133
/// <param name="name">
134
/// XML name of the attribute.
136
/// <param name="type">
137
/// Type of the extension node attribute.
139
/// <param name="description">
140
/// Description of the attribute.
143
/// The type of the attribute is only required when applying this attribute at class level.
144
/// It is not required when it is applied to a field, since the attribute type will be the type of the field.
146
public NodeAttributeAttribute (string name, Type type, string description)
147
: this (name, type, false, description)
152
/// Initializes a new instance
154
/// <param name="name">
155
/// XML name of the attribute.
157
/// <param name="type">
158
/// Type of the extension node attribute.
160
/// <param name="required">
161
/// Indicates whether the attribute is required or not.
164
/// The type of the attribute is only required when applying this attribute at class level.
165
/// It is not required when it is applied to a field, since the attribute type will be the type of the field.
167
public NodeAttributeAttribute (string name, Type type, bool required)
168
: this (name, type, false, null)
173
/// Initializes a new instance
175
/// <param name="name">
176
/// XML name of the attribute.
178
/// <param name="type">
179
/// Type of the extension node attribute.
181
/// <param name="required">
182
/// Indicates whether the attribute is required or not.
184
/// <param name="description">
185
/// Description of the attribute.
188
/// The type of the attribute is only required when applying this attribute at class level.
189
/// It is not required when it is applied to a field, since the attribute type will be the type of the field.
191
public NodeAttributeAttribute (string name, Type type, bool required, string description)
195
this.required = required;
196
this.description = description;
200
/// XML name of the attribute.
203
/// If the name is not specified, the field name to which the [NodeAttribute]
204
/// is applied will be used as name. Providing a name is mandatory when applying
205
/// [NodeAttribute] at class level.
208
get { return name != null ? name : string.Empty; }
209
set { name = value; }
213
/// Indicates whether the attribute is required or not.
215
public bool Required {
216
get { return required; }
217
set { required = value; }
221
/// Type of the extension node attribute.
224
/// To be used only when applying [NodeAttribute] at class level. It is not required when it
225
/// is applied to a field, since the attribute type will be the type of the field.
229
set { type = value; typeName = type.FullName; }
232
internal string TypeName {
233
get { return typeName; }
234
set { typeName = value; type = null; }
238
/// Description of the attribute.
241
/// To be used in the extension point documentation.
243
public string Description {
244
get { return description != null ? description : string.Empty; }
245
set { description = value; }
249
/// When set to True, the value of the field or property is expected to be a string id which
250
/// will be localized by the add-in engine
252
public bool Localizable {
253
get { return localizable; }
254
set { localizable = value; }
258
/// Gets or sets the type of the content.
261
/// Allows specifying the type of the content of a string attribute.
262
/// This value is for documentation purposes only.
264
public ContentType ContentType { get; set; }