Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Inserter.cs
Go to the documentation of this file.
2
3namespace System.Xml.Linq;
4
5internal struct Inserter
6{
7 private readonly XContainer _parent;
8
9 private XNode _previous;
10
11 private string _text;
12
13 public Inserter(XContainer parent, XNode anchor)
14 {
15 _parent = parent;
16 _previous = anchor;
17 _text = null;
18 }
19
20 public void Add(object content)
21 {
22 AddContent(content);
23 if (_text == null)
24 {
25 return;
26 }
27 if (_parent.content == null)
28 {
29 if (_parent.SkipNotify())
30 {
32 }
33 else if (_text.Length > 0)
34 {
36 }
37 else if (_parent is XElement)
38 {
40 if (_parent.content != null)
41 {
43 }
46 }
47 else
48 {
50 }
51 }
52 else if (_text.Length > 0)
53 {
55 {
57 return;
58 }
61 }
62 }
63
64 private void AddContent(object content)
65 {
66 if (content == null)
67 {
68 return;
69 }
70 if (content is XNode n)
71 {
72 AddNode(n);
73 return;
74 }
75 if (content is string s)
76 {
77 AddString(s);
78 return;
79 }
80 if (content is XStreamingElement other)
81 {
83 return;
84 }
85 if (content is object[] array)
86 {
87 object[] array2 = array;
88 foreach (object content2 in array2)
89 {
91 }
92 return;
93 }
94 if (content is IEnumerable enumerable)
95 {
96 {
97 foreach (object item in enumerable)
98 {
100 }
101 return;
102 }
103 }
104 if (content is XAttribute)
105 {
107 }
109 }
110
111 private void AddNode(XNode n)
112 {
114 if (n.parent != null)
115 {
116 n = n.CloneNode();
117 }
118 else
119 {
120 XNode parent = _parent;
121 while (parent.parent != null)
122 {
123 parent = parent.parent;
124 }
125 if (n == parent)
126 {
127 n = n.CloneNode();
128 }
129 }
131 if (_text != null)
132 {
133 if (_text.Length > 0)
134 {
136 {
138 }
139 else
140 {
141 InsertNode(new XText(_text));
142 }
143 }
144 _text = null;
145 }
146 InsertNode(n);
147 }
148
149 private void AddString(string s)
150 {
152 _text += s;
153 }
154
155 private void InsertNode(XNode n)
156 {
158 if (n.parent != null)
159 {
161 }
163 if (_parent.content == null || _parent.content is string)
164 {
165 n.next = n;
167 }
168 else if (_previous == null)
169 {
171 n.next = xNode.next;
172 xNode.next = n;
173 }
174 else
175 {
179 {
181 }
182 }
183 _previous = n;
184 if (flag)
185 {
187 }
188 }
189}
static string InvalidOperation_ExternalCode
Definition SR.cs:50
static string Argument_AddAttribute
Definition SR.cs:14
Definition SR.cs:7
virtual void ValidateNode(XNode node, XNode previous)
virtual void ValidateString(string s)
static string GetStringValue(object value)
static readonly XObjectChangeEventArgs Value
static readonly XObjectChangeEventArgs Add
XContainer parent
Definition XObject.cs:7
bool NotifyChanging(object sender, XObjectChangeEventArgs e)
Definition XObject.cs:428
bool NotifyChanged(object sender, XObjectChangeEventArgs e)
Definition XObject.cs:399
void AddString(string s)
Definition Inserter.cs:149
void AddContent(object content)
Definition Inserter.cs:64
readonly XContainer _parent
Definition Inserter.cs:7
void InsertNode(XNode n)
Definition Inserter.cs:155
void Add(object content)
Definition Inserter.cs:20
void AddNode(XNode n)
Definition Inserter.cs:111
Inserter(XContainer parent, XNode anchor)
Definition Inserter.cs:13