Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetCollectionMethods()

static void System.Runtime.Serialization.CollectionDataContract.GetCollectionMethods ( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type interfaceType,
Type[] addMethodTypeArray,
bool addMethodOnInterface,
out MethodInfo getEnumeratorMethod,
out MethodInfo addMethod )
inlinestaticprivate

Definition at line 1360 of file CollectionDataContract.cs.

1361 {
1362 addMethod = (getEnumeratorMethod = null);
1364 {
1365 addMethod = type.GetMethod("Add", BindingFlags.Instance | BindingFlags.Public, addMethodTypeArray);
1366 if (addMethod == null || addMethod.GetParameters()[0].ParameterType != addMethodTypeArray[0])
1367 {
1369 if (addMethod == null)
1370 {
1371 Type[] interfaces = interfaceType.GetInterfaces();
1372 Array.Sort(interfaces, (Type x, Type y) => string.Compare(x.FullName, y.FullName));
1373 Type[] array = interfaces;
1374 foreach (Type type2 in array)
1375 {
1377 {
1379 if (addMethod == null)
1380 {
1381 break;
1382 }
1383 }
1384 }
1385 }
1386 }
1387 }
1388 else
1389 {
1390 addMethod = type.GetMethod("Add", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, addMethodTypeArray);
1391 }
1392 if (!(getEnumeratorMethod == null))
1393 {
1394 return;
1395 }
1396 getEnumeratorMethod = type.GetMethod("GetEnumerator", BindingFlags.Instance | BindingFlags.Public, Type.EmptyTypes);
1397 if (getEnumeratorMethod == null || !Globals.TypeOfIEnumerator.IsAssignableFrom(getEnumeratorMethod.ReturnType))
1398 {
1399 Type type3 = (from t in interfaceType.GetInterfaces()
1400 where t.FullName.StartsWith("System.Collections.Generic.IEnumerable")
1401 select t).FirstOrDefault();
1402 if (type3 == null)
1403 {
1404 type3 = Globals.TypeOfIEnumerable;
1405 }
1407 }
1408 }
static void FindCollectionMethodsOnInterface([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type interfaceType, ref MethodInfo addMethod, ref MethodInfo getEnumeratorMethod)
static MethodInfo GetIEnumerableGetEnumeratorMethod([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type ienumerableInterface)

References System.array, System.Runtime.Serialization.Dictionary, System.Type.EmptyTypes, System.Runtime.Serialization.CollectionDataContract.FindCollectionMethodsOnInterface(), System.Type.FullName, System.Runtime.Serialization.CollectionDataContract.GetIEnumerableGetEnumeratorMethod(), System.Runtime.Serialization.CollectionDataContract.IsKnownInterface(), System.Array.Sort(), System.type, System.Runtime.Serialization.Globals.TypeOfIEnumerable, and System.Runtime.Serialization.Globals.TypeOfIEnumerator.

Referenced by System.Runtime.Serialization.CollectionDataContract.IsCollectionOrTryCreate().