Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SchemaImporter.cs
Go to the documentation of this file.
3
5
6public abstract class SchemaImporter
7{
9
11
13
15
17
18 private bool _rootImported;
19
21
23
25 {
26 get
27 {
28 if (_context == null)
29 {
30 _context = new ImportContext();
31 }
32 return _context;
33 }
34 }
35
37
39
41
43 {
44 get
45 {
46 if (_schemas == null)
47 {
48 _schemas = new XmlSchemas();
49 }
50 return _schemas;
51 }
52 }
53
55 {
56 get
57 {
58 if (_scope == null)
59 {
60 _scope = new TypeScope();
61 }
62 return _scope;
63 }
64 }
65
67 {
68 get
69 {
70 if (_groupsInUse == null)
71 {
72 _groupsInUse = new NameTable();
73 }
74 return _groupsInUse;
75 }
76 }
77
79 {
80 get
81 {
82 if (_typesInUse == null)
83 {
84 _typesInUse = new NameTable();
85 }
86 return _typesInUse;
87 }
88 }
89
91
92 [RequiresUnreferencedCode("calls SetCache")]
94 {
95 if (!schemas.Contains("http://www.w3.org/2001/XMLSchema"))
96 {
98 schemas.SchemaSet.Add(XmlSchemas.XsdSchema);
99 }
100 if (!schemas.Contains("http://www.w3.org/XML/1998/namespace"))
101 {
103 schemas.SchemaSet.Add(XmlSchemas.XmlSchema);
104 }
105 _schemas = schemas;
107 _context = context;
109 }
110
111 [RequiresUnreferencedCode("calls GetTypeDesc")]
113 {
115 if (!(baseType != null))
116 {
117 return;
118 }
120 if (typeDesc == null)
121 {
122 return;
123 }
126 {
127 while (typeDesc2.BaseTypeDesc != null && typeDesc2.BaseTypeDesc != typeDesc)
128 {
129 typeDesc2 = typeDesc2.BaseTypeDesc;
130 }
131 }
132 if (typeDesc2.BaseTypeDesc != null && typeDesc2.BaseTypeDesc != typeDesc)
133 {
134 throw new InvalidOperationException(System.SR.Format(System.SR.XmlInvalidBaseType, structMapping.TypeDesc.FullName, baseType.FullName, typeDesc2.BaseTypeDesc.FullName));
135 }
137 }
138
139 internal string GenerateUniqueTypeName(string typeName)
140 {
141 typeName = CodeIdentifier.MakeValid(typeName);
142 return TypeIdentifiers.AddUnique(typeName, typeName);
143 }
144
145 [RequiresUnreferencedCode("calls GetTypeDesc")]
147 {
153 structMapping.TypeName = "anyType";
154 structMapping.Namespace = "http://www.w3.org/2001/XMLSchema";
155 return structMapping;
156 }
157
158 [RequiresUnreferencedCode("calls CreateRootMapping")]
160 {
161 if (_root == null)
162 {
164 }
165 return _root;
166 }
167
168 [RequiresUnreferencedCode("calls GetRootMapping")]
170 {
171 if (!_rootImported)
172 {
173 _rootImported = true;
175 }
176 return GetRootMapping();
177 }
178
179 [RequiresUnreferencedCode("calls ImportType")]
181
183 {
184 if (!(name.Namespace == "http://www.w3.org/2001/XMLSchema"))
185 {
186 if (references[name] != null)
187 {
188 throw new InvalidOperationException(string.Format(error, name.Name, name.Namespace));
189 }
190 references[name] = name;
191 }
192 }
193
195 {
196 references[name] = null;
197 }
198
200 {
201 if ((_options & CodeGenerationOptions.EnableDataBinding) != 0)
202 {
203 scope.AddReserved("PropertyChanged");
204 scope.AddReserved("RaisePropertyChanged");
205 }
206 }
207}
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlInvalidBaseType
Definition SR.cs:1604
Definition SR.cs:7
static string MakeValid(string identifier)
string AddUnique(string identifier, object? value)
SchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, ImportContext context)
void MakeDerived(StructMapping structMapping, Type baseType, bool baseTypeCanBeIndirect)
void RemoveReference(XmlQualifiedName name, NameTable references)
readonly CodeGenerationOptions _options
void ImportDerivedTypes(XmlQualifiedName baseName)
void AddReference(XmlQualifiedName name, NameTable references, string error)
void AddReservedIdentifiersForDataBinding(CodeIdentifiers scope)
string GenerateUniqueTypeName(string typeName)
TypeDesc(string name, string fullName, XmlSchemaType dataType, TypeKind kind, TypeDesc baseTypeDesc, TypeFlags flags, string formatterName)
Definition TypeDesc.cs:219
TypeDesc GetTypeDesc(string name, string ns)
Definition TypeScope.cs:224
void SetCache(SchemaObjectCache cache, bool shareTypes)
bool Contains(XmlSchema schema)
void AddReference(XmlSchema schema)
static readonly XmlQualifiedName Empty