~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/mono-addins/Mono.Addins/Mono.Addins/NodeAttributeAttribute.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// NodeAttributeAttribute.cs
 
3
//
 
4
// Author:
 
5
//   Lluis Sanchez Gual
 
6
//
 
7
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
 
8
//
 
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:
 
16
// 
 
17
// The above copyright notice and this permission notice shall be
 
18
// included in all copies or substantial portions of the Software.
 
19
// 
 
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.
 
27
//
 
28
 
 
29
 
 
30
using System;
 
31
 
 
32
namespace Mono.Addins
 
33
{
 
34
        /// <summary>
 
35
        /// Indicates that a field or property is bound to a node attribute
 
36
        /// </summary>
 
37
        [AttributeUsage (AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple=true)]
 
38
        public class NodeAttributeAttribute: Attribute
 
39
        {
 
40
                string name;
 
41
                bool required;
 
42
                bool localizable;
 
43
                Type type;
 
44
                string typeName;
 
45
                string description;
 
46
                
 
47
                /// <summary>
 
48
                /// Initializes a new instance
 
49
                /// </summary>
 
50
                public NodeAttributeAttribute ()
 
51
                {
 
52
                }
 
53
                
 
54
                /// <summary>
 
55
                /// Initializes a new instance
 
56
                /// </summary>
 
57
                /// <param name="name">
 
58
                /// XML name of the attribute.
 
59
                /// </param>
 
60
                public NodeAttributeAttribute (string name)
 
61
                        :this (name, false, null)
 
62
                {
 
63
                }
 
64
                
 
65
                /// <summary>
 
66
                /// Initializes a new instance
 
67
                /// </summary>
 
68
                /// <param name="name">
 
69
                /// XML name of the attribute.
 
70
                /// </param>
 
71
                /// <param name="description">
 
72
                /// Description of the attribute.
 
73
                /// </param>
 
74
                public NodeAttributeAttribute (string name, string description)
 
75
                        :this (name, false, description)
 
76
                {
 
77
                }
 
78
                
 
79
                /// <summary>
 
80
                /// Initializes a new instance
 
81
                /// </summary>
 
82
                /// <param name="name">
 
83
                /// XML name of the attribute.
 
84
                /// </param>
 
85
                /// <param name="required">
 
86
                /// Indicates whether the attribute is required or not.
 
87
                /// </param>
 
88
                public NodeAttributeAttribute (string name, bool required)
 
89
                        : this (name, required, null)
 
90
                {
 
91
                }
 
92
                
 
93
                /// <summary>
 
94
                /// Initializes a new instance
 
95
                /// </summary>
 
96
                /// <param name="name">
 
97
                /// XML name of the attribute.
 
98
                /// </param>
 
99
                /// <param name="required">
 
100
                /// Indicates whether the attribute is required or not.
 
101
                /// </param>
 
102
                /// <param name="description">
 
103
                /// Description of the attribute.
 
104
                /// </param>
 
105
                public NodeAttributeAttribute (string name, bool required, string description)
 
106
                {
 
107
                        this.name = name;
 
108
                        this.required = required;
 
109
                        this.description = description;
 
110
                }
 
111
                
 
112
                /// <summary>
 
113
                /// Initializes a new instance
 
114
                /// </summary>
 
115
                /// <param name="name">
 
116
                /// XML name of the attribute.
 
117
                /// </param>
 
118
                /// <param name="type">
 
119
                /// Type of the extension node attribute.
 
120
                /// </param>
 
121
                /// <remarks>
 
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.
 
124
                /// </remarks>
 
125
                public NodeAttributeAttribute (string name, Type type)
 
126
                        : this (name, type, false, null)
 
127
                {
 
128
                }
 
129
                
 
130
                /// <summary>
 
131
                /// Initializes a new instance
 
132
                /// </summary>
 
133
                /// <param name="name">
 
134
                /// XML name of the attribute.
 
135
                /// </param>
 
136
                /// <param name="type">
 
137
                /// Type of the extension node attribute.
 
138
                /// </param>
 
139
                /// <param name="description">
 
140
                /// Description of the attribute.
 
141
                /// </param>
 
142
                /// <remarks>
 
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.
 
145
                /// </remarks>
 
146
                public NodeAttributeAttribute (string name, Type type, string description)
 
147
                        : this (name, type, false, description)
 
148
                {
 
149
                }
 
150
                
 
151
                /// <summary>
 
152
                /// Initializes a new instance
 
153
                /// </summary>
 
154
                /// <param name="name">
 
155
                /// XML name of the attribute.
 
156
                /// </param>
 
157
                /// <param name="type">
 
158
                /// Type of the extension node attribute.
 
159
                /// </param>
 
160
                /// <param name="required">
 
161
                /// Indicates whether the attribute is required or not.
 
162
                /// </param>
 
163
                /// <remarks>
 
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.
 
166
                /// </remarks>
 
167
                public NodeAttributeAttribute (string name, Type type, bool required)
 
168
                        : this (name, type, false, null)
 
169
                {
 
170
                }
 
171
                
 
172
                /// <summary>
 
173
                /// Initializes a new instance
 
174
                /// </summary>
 
175
                /// <param name="name">
 
176
                /// XML name of the attribute.
 
177
                /// </param>
 
178
                /// <param name="type">
 
179
                /// Type of the extension node attribute.
 
180
                /// </param>
 
181
                /// <param name="required">
 
182
                /// Indicates whether the attribute is required or not.
 
183
                /// </param>
 
184
                /// <param name="description">
 
185
                /// Description of the attribute.
 
186
                /// </param>
 
187
                /// <remarks>
 
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.
 
190
                /// </remarks>
 
191
                public NodeAttributeAttribute (string name, Type type, bool required, string description)
 
192
                {
 
193
                        this.name = name;
 
194
                        this.type = type;
 
195
                        this.required = required;
 
196
                        this.description = description;
 
197
                }
 
198
                
 
199
                /// <summary>
 
200
                /// XML name of the attribute.
 
201
                /// </summary>
 
202
                /// <remarks>
 
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.
 
206
                /// </remarks>
 
207
                public string Name {
 
208
                        get { return name != null ? name : string.Empty; }
 
209
                        set { name = value; }
 
210
                }
 
211
                
 
212
                /// <summary>
 
213
                /// Indicates whether the attribute is required or not.
 
214
                /// </summary>
 
215
                public bool Required {
 
216
                        get { return required; }
 
217
                        set { required = value; }
 
218
                }
 
219
                
 
220
                /// <summary>
 
221
                /// Type of the extension node attribute.
 
222
                /// </summary>
 
223
                /// <remarks>
 
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.
 
226
                /// </remarks>
 
227
                public Type Type {
 
228
                        get { return type; }
 
229
                        set { type = value; typeName = type.FullName; }
 
230
                }
 
231
                
 
232
                internal string TypeName {
 
233
                        get { return typeName; }
 
234
                        set { typeName = value; type = null; }
 
235
                }
 
236
                
 
237
                /// <summary>
 
238
                /// Description of the attribute.
 
239
                /// </summary>
 
240
                /// <remarks>
 
241
                /// To be used in the extension point documentation.
 
242
                /// </remarks>
 
243
                public string Description {
 
244
                        get { return description != null ? description : string.Empty; }
 
245
                        set { description = value; }
 
246
                }
 
247
 
 
248
                /// <summary>
 
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
 
251
                /// </summary>
 
252
                public bool Localizable {
 
253
                        get { return localizable; }
 
254
                        set { localizable = value; }
 
255
                }
 
256
                
 
257
                /// <summary>
 
258
                /// Gets or sets the type of the content.
 
259
                /// </summary>
 
260
                /// <remarks>
 
261
                /// Allows specifying the type of the content of a string attribute.
 
262
                /// This value is for documentation purposes only.
 
263
                /// </remarks>
 
264
                public ContentType ContentType { get; set; }
 
265
        }
 
266
}