Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SchemaObjectCache.cs
Go to the documentation of this file.
5
7
8internal sealed class SchemaObjectCache
9{
11
13
15
17
18 internal Hashtable looks = new Hashtable();
19
21 {
22 get
23 {
24 if (_graph == null)
25 {
26 _graph = new Hashtable();
27 }
28 return _graph;
29 }
30 }
31
33 {
34 get
35 {
36 if (_hash == null)
37 {
38 _hash = new Hashtable();
39 }
40 return _hash;
41 }
42 }
43
45 {
46 get
47 {
48 if (_objectCache == null)
49 {
50 _objectCache = new Hashtable();
51 }
52 return _objectCache;
53 }
54 }
55
57 {
58 get
59 {
60 if (_warnings == null)
61 {
63 }
64 return _warnings;
65 }
66 }
67
69 {
70 if (item == null)
71 {
72 return null;
73 }
74 if (qname == null || qname.IsEmpty)
75 {
76 return null;
77 }
78 string key = item.GetType().Name + ":" + qname.ToString();
80 if (arrayList == null)
81 {
82 arrayList = new ArrayList();
84 }
85 for (int i = 0; i < arrayList.Count; i++)
86 {
88 if (xmlSchemaObject == item)
89 {
90 return xmlSchemaObject;
91 }
93 {
94 return xmlSchemaObject;
95 }
97 Warnings.Add("DEBUG:Cached item key:\r\n" + (string)looks[xmlSchemaObject] + "\r\nnew item key:\r\n" + (string)looks[item]);
98 }
99 arrayList.Add(item);
100 return item;
101 }
102
104 {
105 if (o1 == o2)
106 {
107 return true;
108 }
109 if (o1.GetType() != o2.GetType())
110 {
111 return false;
112 }
113 if (Hash[o1] == null)
114 {
115 Hash[o1] = GetHash(o1);
116 }
117 int num = (int)Hash[o1];
118 int hash = GetHash(o2);
119 if (num != hash)
120 {
121 return false;
122 }
123 if (shareTypes)
124 {
125 return CompositeHash(o1, num) == CompositeHash(o2, hash);
126 }
127 return true;
128 }
129
131 {
132 if (refs[o] == null)
133 {
134 refs[o] = o;
135 deps.Add(o);
137 {
138 for (int i = 0; i < arrayList.Count; i++)
139 {
141 }
142 }
143 }
144 return deps;
145 }
146
148 {
150 double num = 0.0;
151 for (int i = 0; i < dependencies.Count; i++)
152 {
153 object obj = Hash[dependencies[i]];
154 if (obj is int)
155 {
156 num += (double)((int)obj / dependencies.Count);
157 }
158 }
159 return (int)num;
160 }
161
162 [RequiresUnreferencedCode("creates SchemaGraph")]
163 internal void GenerateSchemaGraph(XmlSchemas schemas)
164 {
166 ArrayList items = schemaGraph.GetItems();
167 for (int i = 0; i < items.Count; i++)
168 {
169 GetHash((XmlSchemaObject)items[i]);
170 }
171 }
172
174 {
175 object obj = Hash[o];
176 if (obj != null && !(obj is XmlSchemaObject))
177 {
178 return (int)obj;
179 }
180 string text = ToString(o, new SchemaObjectWriter());
181 looks[o] = text;
182 int hashCode = text.GetHashCode();
183 Hash[o] = hashCode;
184 return hashCode;
185 }
186
188 {
189 return writer.WriteXmlSchemaObject(o);
190 }
191}
virtual int Add(object? value)
static string XmlMismatchSchemaObjects
Definition SR.cs:1722
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
XmlSchemaObject AddItem(XmlSchemaObject item, XmlQualifiedName qname, XmlSchemas schemas)
string ToString(XmlSchemaObject o, SchemaObjectWriter writer)
ArrayList GetDependencies(XmlSchemaObject o, ArrayList deps, Hashtable refs)
bool Match(XmlSchemaObject o1, XmlSchemaObject o2, bool shareTypes)
int CompositeHash(XmlSchemaObject o, int hash)