Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SurrogateSelector.cs
Go to the documentation of this file.
2
4{
6
8
10 {
11 if (type == null)
12 {
13 throw new ArgumentNullException("type");
14 }
15 if (surrogate == null)
16 {
17 throw new ArgumentNullException("surrogate");
18 }
19 SurrogateKey key = new SurrogateKey(type, context);
21 }
22
23 private static bool HasCycle(ISurrogateSelector selector)
24 {
27 while (surrogateSelector != null)
28 {
29 surrogateSelector = surrogateSelector.GetNextSelector();
30 if (surrogateSelector == null)
31 {
32 return true;
33 }
35 {
36 return false;
37 }
38 surrogateSelector = surrogateSelector.GetNextSelector();
39 surrogateSelector2 = surrogateSelector2.GetNextSelector();
41 {
42 return false;
43 }
44 }
45 return true;
46 }
47
48 public virtual void ChainSelector(ISurrogateSelector selector)
49 {
50 if (selector == null)
51 {
52 throw new ArgumentNullException("selector");
53 }
54 if (selector == this)
55 {
57 }
58 if (!HasCycle(selector))
59 {
61 }
62 ISurrogateSelector nextSelector = selector.GetNextSelector();
64 while (nextSelector != null && nextSelector != this)
65 {
67 nextSelector = nextSelector.GetNextSelector();
68 }
69 if (nextSelector == this)
70 {
72 }
73 nextSelector = selector;
75 while (nextSelector != null)
76 {
78 if (nextSelector == null)
79 {
80 break;
81 }
83 {
85 }
89 {
91 }
92 }
94 _nextSelector = selector;
95 if (nextSelector2 != null)
96 {
97 surrogateSelector.ChainSelector(nextSelector2);
98 }
99 }
100
102 {
103 return _nextSelector;
104 }
105
107 {
108 if (type == null)
109 {
110 throw new ArgumentNullException("type");
111 }
112 selector = this;
113 SurrogateKey key = new SurrogateKey(type, context);
115 if (serializationSurrogate != null)
116 {
117 return serializationSurrogate;
118 }
119 if (_nextSelector != null)
120 {
121 return _nextSelector.GetSurrogate(type, context, out selector);
122 }
123 return null;
124 }
125
126 public virtual void RemoveSurrogate(Type type, StreamingContext context)
127 {
128 if (type == null)
129 {
130 throw new ArgumentNullException("type");
131 }
132 SurrogateKey key = new SurrogateKey(type, context);
134 }
135}
virtual void Remove(object key)
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
virtual void RemoveSurrogate(Type type, StreamingContext context)
virtual void ChainSelector(ISurrogateSelector selector)
virtual ? ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector)
static bool HasCycle(ISurrogateSelector selector)
virtual void AddSurrogate(Type type, StreamingContext context, ISerializationSurrogate surrogate)
static string Serialization_SurrogateCycle
Definition SR.cs:136
static string Serialization_SurrogateCycleInArgument
Definition SR.cs:134
Definition SR.cs:7
ISerializationSurrogate? GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector)