/
CodeAttributeDeclaration.cs
55 lines (45 loc) · 1.58 KB
/
CodeAttributeDeclaration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.CodeDom
{
public class CodeAttributeDeclaration
{
private string _name;
private readonly CodeAttributeArgumentCollection _arguments = new CodeAttributeArgumentCollection();
private CodeTypeReference _attributeType;
public CodeAttributeDeclaration() { }
public CodeAttributeDeclaration(string name)
{
Name = name;
}
public CodeAttributeDeclaration(string name, params CodeAttributeArgument[] arguments)
{
Name = name;
Arguments.AddRange(arguments);
}
public CodeAttributeDeclaration(CodeTypeReference attributeType) : this(attributeType, null) { }
public CodeAttributeDeclaration(CodeTypeReference attributeType, params CodeAttributeArgument[] arguments)
{
_attributeType = attributeType;
if (attributeType != null)
{
_name = attributeType.BaseType;
}
if (arguments != null)
{
Arguments.AddRange(arguments);
}
}
public string Name
{
get => _name ?? string.Empty;
set
{
_name = value;
_attributeType = new CodeTypeReference(_name);
}
}
public CodeAttributeArgumentCollection Arguments => _arguments;
public CodeTypeReference AttributeType => _attributeType;
}
}