Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
IdentityReferenceCollection.cs
Go to the documentation of this file.
3
5
6public class IdentityReferenceCollection : ICollection<IdentityReference>, IEnumerable<IdentityReference>, IEnumerable
7{
9
10 public int Count => _identities.Count;
11
13
14 public IdentityReference this[int index]
15 {
16 get
17 {
18 return _identities[index];
19 }
20 set
21 {
22 if ((object)value == null)
23 {
24 throw new ArgumentNullException("value");
25 }
27 }
28 }
29
31
33 : this(0)
34 {
35 }
36
41
43 {
45 }
46
47 public void Add(IdentityReference identity)
48 {
49 if (identity == null)
50 {
51 throw new ArgumentNullException("identity");
52 }
53 _identities.Add(identity);
54 }
55
56 public bool Remove(IdentityReference identity)
57 {
58 if (identity == null)
59 {
60 throw new ArgumentNullException("identity");
61 }
62 if (Contains(identity))
63 {
64 return _identities.Remove(identity);
65 }
66 return false;
67 }
68
69 public void Clear()
70 {
72 }
73
74 public bool Contains(IdentityReference identity)
75 {
76 if (identity == null)
77 {
78 throw new ArgumentNullException("identity");
79 }
80 return _identities.Contains(identity);
81 }
82
87
92
97
99 {
100 if (targetType == null)
101 {
102 throw new ArgumentNullException("targetType");
103 }
104 if (!targetType.IsSubclassOf(typeof(IdentityReference)))
105 {
107 }
108 if (Identities.Count == 0)
109 {
110 return new IdentityReferenceCollection();
111 }
112 int num = 0;
113 int num2 = 0;
114 for (int i = 0; i < Identities.Count; i++)
115 {
116 Type type = Identities[i].GetType();
117 if (type == targetType)
118 {
119 continue;
120 }
122 {
123 num++;
124 continue;
125 }
126 if (type == typeof(NTAccount))
127 {
128 num2++;
129 continue;
130 }
131 throw new NotSupportedException();
132 }
133 bool flag = false;
136 if (num == Count)
137 {
138 flag = true;
140 }
141 else if (num > 0)
142 {
144 }
145 if (num2 == Count)
146 {
147 flag = true;
149 }
150 else if (num2 > 0)
151 {
153 }
155 if (!flag)
156 {
158 for (int j = 0; j < Identities.Count; j++)
159 {
161 Type type2 = identityReference.GetType();
162 if (type2 == targetType)
163 {
164 continue;
165 }
167 {
169 continue;
170 }
171 if (type2 == typeof(NTAccount))
172 {
174 continue;
175 }
176 throw new NotSupportedException();
177 }
178 }
179 bool someFailed = false;
182 if (num > 0)
183 {
185 if (flag && !(forceSuccess && someFailed))
186 {
188 }
189 }
190 if (num2 > 0)
191 {
193 if (flag && !(forceSuccess && someFailed))
194 {
196 }
197 }
199 {
202 {
204 {
205 if (item.GetType() != targetType)
206 {
208 }
209 }
210 }
212 {
214 {
215 if (item2.GetType() != targetType)
216 {
218 }
219 }
220 }
222 }
223 if (!flag)
224 {
225 num = 0;
226 num2 = 0;
228 for (int k = 0; k < Identities.Count; k++)
229 {
231 Type type3 = identityReference2.GetType();
232 if (type3 == targetType)
233 {
235 continue;
236 }
238 {
240 continue;
241 }
242 if (type3 == typeof(NTAccount))
243 {
245 continue;
246 }
247 throw new NotSupportedException();
248 }
249 }
251 }
252}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
void Add(TKey key, TValue value)
static string IdentityReference_IdentityNotMapped
Definition SR.cs:44
static string IdentityReference_MustBeIdentityReference
Definition SR.cs:50
Definition SR.cs:7
IdentityReferenceCollection Translate(Type targetType, bool forceSuccess)
IdentityReferenceCollection Translate(Type targetType)
override IdentityReference Translate(Type targetType)
Definition NTAccount.cs:72
override IdentityReference Translate(Type targetType)
new IEnumerator< T > GetEnumerator()