Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XMLSchema.cs
Go to the documentation of this file.
5using System.Xml;
6
7namespace System.Data;
8
9internal class XMLSchema
10{
11 [RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
13 {
15 }
16
17 [RequiresUnreferencedCode("Calls into TypeDescriptor.GetProperties. Type cannot be statically discovered.")]
18 internal static void SetProperties(object instance, XmlAttributeCollection attrs)
19 {
20 for (int i = 0; i < attrs.Count; i++)
21 {
22 if (!(attrs[i].NamespaceURI == "urn:schemas-microsoft-com:xml-msdata"))
23 {
24 continue;
25 }
26 string localName = attrs[i].LocalName;
27 string value = attrs[i].Value;
28 switch (localName)
29 {
30 case "Expression":
31 if (instance is DataColumn)
32 {
33 continue;
34 }
35 break;
36 case "DefaultValue":
37 case "RemotingFormat":
38 continue;
39 }
41 if (propertyDescriptor == null)
42 {
43 continue;
44 }
47 object value2;
48 if (converter.CanConvertFrom(typeof(string)))
49 {
50 value2 = converter.ConvertFromInvariantString(value);
51 }
52 else if (propertyType == typeof(Type))
53 {
55 }
56 else
57 {
59 {
61 }
63 }
64 propertyDescriptor.SetValue(instance, value2);
65 }
66 }
67
68 internal static bool FEqualIdentity(XmlNode node, string name, string ns)
69 {
70 if (node != null && node.LocalName == name && node.NamespaceURI == ns)
71 {
72 return true;
73 }
74 return false;
75 }
76
77 internal static bool GetBooleanAttribute(XmlElement element, string attrName, string attrNS, bool defVal)
78 {
79 string attribute = element.GetAttribute(attrName, attrNS);
80 if (attribute == null || attribute.Length == 0)
81 {
82 return defVal;
83 }
84 switch (attribute)
85 {
86 case "true":
87 case "1":
88 return true;
89 case "false":
90 case "0":
91 return false;
92 default:
94 }
95 }
96
97 internal static string GenUniqueColumnName(string proposedName, DataTable table)
98 {
99 if (table.Columns.IndexOf(proposedName) >= 0)
100 {
101 for (int i = 0; i <= table.Columns.Count; i++)
102 {
103 string text = proposedName + "_" + i.ToString(CultureInfo.InvariantCulture);
104 if (table.Columns.IndexOf(text) < 0)
105 {
106 return text;
107 }
108 }
109 }
110 return proposedName;
111 }
112}
static PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type componentType)
static TypeConverter GetConverter(object component)
static Type GetType(string value)
DataColumnCollection Columns
Definition DataTable.cs:327
static Exception InvalidAttributeValue(string name, string value)
static Exception CannotConvert(string name, string type)
static void SetProperties(object instance, XmlAttributeCollection attrs)
Definition XMLSchema.cs:18
static bool GetBooleanAttribute(XmlElement element, string attrName, string attrNS, bool defVal)
Definition XMLSchema.cs:77
static bool FEqualIdentity(XmlNode node, string name, string ns)
Definition XMLSchema.cs:68
static string GenUniqueColumnName(string proposedName, DataTable table)
Definition XMLSchema.cs:97
static TypeConverter GetConverter(Type type)
Definition XMLSchema.cs:12
static CultureInfo InvariantCulture
virtual string GetAttribute(string name)