/
XmlElementAttribute.cs
141 lines (126 loc) · 3.57 KB
/
XmlElementAttribute.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Xml.Schema;
namespace System.Xml.Serialization
{
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)]
public class XmlElementAttribute : System.Attribute
{
private string? _elementName;
private Type? _type;
private string? _ns;
private string? _dataType;
private bool _nullable;
private bool _nullableSpecified;
private XmlSchemaForm _form = XmlSchemaForm.None;
private int _order = -1;
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public XmlElementAttribute()
{
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public XmlElementAttribute(string? elementName)
{
_elementName = elementName;
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public XmlElementAttribute(Type? type)
{
_type = type;
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public XmlElementAttribute(string? elementName, Type? type)
{
_elementName = elementName;
_type = type;
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public Type? Type
{
get { return _type; }
set { _type = value; }
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
[AllowNull]
public string ElementName
{
get { return _elementName ?? string.Empty; }
set { _elementName = value; }
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public string? Namespace
{
get { return _ns; }
set { _ns = value; }
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
[AllowNull]
public string DataType
{
get { return _dataType ?? string.Empty; }
set { _dataType = value; }
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public bool IsNullable
{
get { return _nullable; }
set
{
_nullable = value;
_nullableSpecified = true;
}
}
internal bool IsNullableSpecified
{
get { return _nullableSpecified; }
}
internal bool GetIsNullableSpecified()
{
return IsNullableSpecified;
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public XmlSchemaForm Form
{
get { return _form; }
set { _form = value; }
}
/// <devdoc>
/// <para>[To be supplied.]</para>
/// </devdoc>
public int Order
{
get { return _order; }
set
{
if (value < 0)
throw new ArgumentException(SR.XmlDisallowNegativeValues, "Order");
_order = value;
}
}
}
}