// Token: 0x0600177B RID: 6011 RVA: 0x0006F0E0 File Offset: 0x0006D2E0 public static void GetDictionaryKeyValueTypes(Type dictionaryType, out Type keyType, out Type valueType) { Class_517.ArgumentNotNull(dictionaryType, "type"); Type type; if (Class_514.ImplementsGenericDefinition(dictionaryType, typeof(IDictionary <, >), out type)) { if (type.IsGenericTypeDefinition) { throw new Exception("Type {0} is not a dictionary.".FormatWith(CultureInfo.InvariantCulture, dictionaryType)); } Type[] genericArguments = type.GetGenericArguments(); keyType = genericArguments[0]; valueType = genericArguments[1]; return; } else { if (typeof(IDictionary).IsAssignableFrom(dictionaryType)) { keyType = null; valueType = null; return; } throw new Exception("Type {0} is not a dictionary.".FormatWith(CultureInfo.InvariantCulture, dictionaryType)); } }
// Token: 0x06001784 RID: 6020 RVA: 0x0006F5E8 File Offset: 0x0006D7E8 private static bool IsOverridenGenericMember(MemberInfo memberInfo, BindingFlags bindingAttr) { if (memberInfo.MemberType != MemberTypes.Property) { return(false); } PropertyInfo propertyInfo = (PropertyInfo)memberInfo; if (!propertyInfo.IsVirtual()) { return(false); } Type declaringType = propertyInfo.DeclaringType; if (!declaringType.IsGenericType) { return(false); } Type genericTypeDefinition = declaringType.GetGenericTypeDefinition(); if (genericTypeDefinition == null) { return(false); } MemberInfo[] member = genericTypeDefinition.GetMember(propertyInfo.Name, bindingAttr); if (member.Length == 0) { return(false); } Type memberUnderlyingType = Class_514.GetMemberUnderlyingType(member[0]); return(memberUnderlyingType.IsGenericParameter); }
// Token: 0x0600177D RID: 6013 RVA: 0x0006F204 File Offset: 0x0006D404 public static bool IsIndexedProperty(MemberInfo member) { Class_517.ArgumentNotNull(member, "member"); PropertyInfo propertyInfo = member as PropertyInfo; return(propertyInfo != null && Class_514.IsIndexedProperty(propertyInfo)); }
// Token: 0x0600176C RID: 5996 RVA: 0x0006EC6C File Offset: 0x0006CE6C public static string GetTypeName(Type t, FormatterAssemblyStyle assemblyFormat, SerializationBinder binder) { string text2; if (binder != null) { string text; string str; binder.BindToName(t, out text, out str); text2 = str + ((text == null) ? "" : (", " + text)); } else { text2 = t.AssemblyQualifiedName; } switch (assemblyFormat) { case FormatterAssemblyStyle.Simple: return(Class_514.RemoveAssemblyDetails(text2)); case FormatterAssemblyStyle.Full: return(text2); default: throw new ArgumentOutOfRangeException(); } }
// Token: 0x060016AE RID: 5806 RVA: 0x0006AC24 File Offset: 0x00068E24 public static Class_496 GetTypeCode(Type t, out bool isEnum) { Class_496 result; if (Class_499.TypeCodeMap.TryGetValue(t, out result)) { isEnum = false; return(result); } if (t.IsEnum) { isEnum = true; return(Class_499.GetTypeCode(Enum.GetUnderlyingType(t))); } if (Class_514.IsNullableType(t)) { Type underlyingType = Nullable.GetUnderlyingType(t); if (underlyingType.IsEnum) { Type t2 = typeof(Nullable <>).MakeGenericType(new Type[] { Enum.GetUnderlyingType(underlyingType) }); isEnum = true; return(Class_499.GetTypeCode(t2)); } } isEnum = false; return(Class_496.Object); }
// Token: 0x0600177A RID: 6010 RVA: 0x0006F044 File Offset: 0x0006D244 public static Type GetCollectionItemType(Type type) { Class_517.ArgumentNotNull(type, "type"); if (type.IsArray) { return(type.GetElementType()); } Type type2; if (Class_514.ImplementsGenericDefinition(type, typeof(IEnumerable <>), out type2)) { if (type2.IsGenericTypeDefinition) { throw new Exception("Type {0} is not a collection.".FormatWith(CultureInfo.InvariantCulture, type)); } return(type2.GetGenericArguments()[0]); } else { if (typeof(IEnumerable).IsAssignableFrom(type)) { return(null); } throw new Exception("Type {0} is not a collection.".FormatWith(CultureInfo.InvariantCulture, type)); } }
// Token: 0x06001773 RID: 6003 RVA: 0x0006EE5A File Offset: 0x0006D05A public static Type EnsureNotNullableType(Type t) { if (!Class_514.IsNullableType(t)) { return(t); } return(Nullable.GetUnderlyingType(t)); }
// Token: 0x0600178C RID: 6028 RVA: 0x0006F9A0 File Offset: 0x0006DBA0 public static IEnumerable <FieldInfo> GetFields(Type targetType, BindingFlags bindingAttr) { Class_517.ArgumentNotNull(targetType, "targetType"); List <MemberInfo> list = new List <MemberInfo>(targetType.GetFields(bindingAttr)); Class_514.GetChildPrivateFields(list, targetType, bindingAttr); return(list.Cast <FieldInfo>()); }
// Token: 0x06001786 RID: 6022 RVA: 0x0006F680 File Offset: 0x0006D880 public static T GetAttribute <T>(object attributeProvider, bool inherit) where T : Attribute { T[] attributes = Class_514.GetAttributes <T>(attributeProvider, inherit); if (attributes == null) { return(default(T)); } return(attributes.FirstOrDefault <T>()); }
// Token: 0x06001787 RID: 6023 RVA: 0x0006F6AC File Offset: 0x0006D8AC public static T[] GetAttributes <T>(object attributeProvider, bool inherit) where T : Attribute { Attribute[] attributes = Class_514.GetAttributes(attributeProvider, typeof(T), inherit); T[] array = attributes as T[]; if (array != null) { return(array); } return(attributes.Cast <T>().ToArray <T>()); }
// Token: 0x06001778 RID: 6008 RVA: 0x0006EF98 File Offset: 0x0006D198 public static bool InheritsGenericDefinition(Type type, Type genericClassDefinition, out Type implementingType) { Class_517.ArgumentNotNull(type, "type"); Class_517.ArgumentNotNull(genericClassDefinition, "genericClassDefinition"); if (!genericClassDefinition.IsClass || !genericClassDefinition.IsGenericTypeDefinition) { throw new ArgumentNullException("'{0}' is not a generic class definition.".FormatWith(CultureInfo.InvariantCulture, genericClassDefinition)); } return(Class_514.InheritsGenericDefinitionInternal(type, genericClassDefinition, out implementingType)); }
// Token: 0x06001668 RID: 5736 RVA: 0x0006A3D8 File Offset: 0x000685D8 public virtual Func <T> kmethod_4047 <T>(Type arg_0) { Class_488 <T> .NClass_2 nclass_ = new Class_488 <T> .NClass_2(); nclass_.type = arg_0; Class_517.ArgumentNotNull(nclass_.type, "type"); if (nclass_.type.IsValueType) { return(new Func <T>(nclass_.< CreateDefaultConstructor > b__7)); } nclass_.constructorInfo = Class_514.GetDefaultConstructor(nclass_.type, true); return(new Func <T>(nclass_.< CreateDefaultConstructor > b__8)); }
// Token: 0x06001789 RID: 6025 RVA: 0x0006F83C File Offset: 0x0006DA3C public static void SplitFullyQualifiedTypeName(string fullyQualifiedTypeName, out string typeName, out string assemblyName) { int?assemblyDelimiterIndex = Class_514.GetAssemblyDelimiterIndex(fullyQualifiedTypeName); if (assemblyDelimiterIndex != null) { typeName = fullyQualifiedTypeName.Substring(0, assemblyDelimiterIndex.Value).Trim(); assemblyName = fullyQualifiedTypeName.Substring(assemblyDelimiterIndex.Value + 1, fullyQualifiedTypeName.Length - assemblyDelimiterIndex.Value - 1).Trim(); return; } typeName = fullyQualifiedTypeName; assemblyName = null; }
// Token: 0x0600178E RID: 6030 RVA: 0x0006FA44 File Offset: 0x0006DC44 public static IEnumerable <PropertyInfo> GetProperties(Type targetType, BindingFlags bindingAttr) { Class_517.ArgumentNotNull(targetType, "targetType"); List <PropertyInfo> list = new List <PropertyInfo>(targetType.GetProperties(bindingAttr)); Class_514.GetChildPrivateProperties(list, targetType, bindingAttr); for (int i = 0; i < list.Count; i++) { PropertyInfo propertyInfo = list[i]; if (propertyInfo.DeclaringType != targetType) { PropertyInfo value = (PropertyInfo)Class_514.GetMemberInfoFromType(propertyInfo.DeclaringType, propertyInfo); list[i] = value; } } return(list); }
// Token: 0x060016B8 RID: 5816 RVA: 0x0006B364 File Offset: 0x00069564 public static object ConvertOrCast(object initialValue, CultureInfo culture, Type targetType) { if (targetType == typeof(object)) { return(initialValue); } if (initialValue == null && Class_514.IsNullable(targetType)) { return(null); } object result; if (Class_499.TryConvert(initialValue, culture, targetType, out result)) { return(result); } return(Class_499.EnsureTypeAssignable(initialValue, Class_514.GetObjectType(initialValue), targetType)); }
// Token: 0x06001779 RID: 6009 RVA: 0x0006EFF0 File Offset: 0x0006D1F0 private static bool InheritsGenericDefinitionInternal(Type currentType, Type genericClassDefinition, out Type implementingType) { if (currentType.IsGenericType) { Type genericTypeDefinition = currentType.GetGenericTypeDefinition(); if (genericClassDefinition == genericTypeDefinition) { implementingType = currentType; return(true); } } if (currentType.BaseType == null) { implementingType = null; return(false); } return(Class_514.InheritsGenericDefinitionInternal(currentType.BaseType, genericClassDefinition, out implementingType)); }
// Token: 0x06001790 RID: 6032 RVA: 0x0006FACC File Offset: 0x0006DCCC private static void GetChildPrivateProperties(IList <PropertyInfo> initialProperties, Type targetType, BindingFlags bindingAttr) { while ((targetType = targetType.BaseType) != null) { PropertyInfo[] properties = targetType.GetProperties(bindingAttr); for (int i = 0; i < properties.Length; i++) { PropertyInfo subTypeProperty2 = properties[i]; PropertyInfo subTypeProperty = subTypeProperty2; if (!Class_514.IsPublic(subTypeProperty)) { int num = initialProperties.IndexOf((PropertyInfo p) => p.Name == subTypeProperty.Name); if (num == -1) { initialProperties.Add(subTypeProperty); } else { PropertyInfo property = initialProperties[num]; if (!Class_514.IsPublic(property)) { initialProperties[num] = subTypeProperty; } } } else if (!subTypeProperty.IsVirtual()) { int num2 = initialProperties.IndexOf((PropertyInfo p) => p.Name == subTypeProperty.Name && p.DeclaringType == subTypeProperty.DeclaringType); if (num2 == -1) { initialProperties.Add(subTypeProperty); } } else { int num3 = initialProperties.IndexOf((PropertyInfo p) => p.Name == subTypeProperty.Name && p.IsVirtual() && p.GetBaseDefinition() != null && p.GetBaseDefinition().DeclaringType.IsAssignableFrom(subTypeProperty.DeclaringType)); if (num3 == -1) { initialProperties.Add(subTypeProperty); } } } } }
// Token: 0x060016B9 RID: 5817 RVA: 0x0006B3BC File Offset: 0x000695BC private static object EnsureTypeAssignable(object value, Type initialType, Type targetType) { Type type = (value != null) ? value.GetType() : null; if (value != null) { if (targetType.IsAssignableFrom(type)) { return(value); } Func <object, object> func = Class_499.CastConverters.Get(new Class_499.TypeConvertKey(type, targetType)); if (func != null) { return(func(value)); } } else if (Class_514.IsNullable(targetType)) { return(null); } throw new ArgumentException("Could not cast or convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, (initialType != null) ? initialType.ToString() : "{null}", targetType)); }
// Token: 0x06001783 RID: 6019 RVA: 0x0006F488 File Offset: 0x0006D688 public static List <MemberInfo> GetFieldsAndProperties(Type type, BindingFlags bindingAttr) { List <MemberInfo> list = new List <MemberInfo>(); list.AddRange(Class_514.GetFields(type, bindingAttr)); list.AddRange(Class_514.GetProperties(type, bindingAttr)); List <MemberInfo> list2 = new List <MemberInfo>(list.Count); foreach (IGrouping <string, MemberInfo> source in from m in list group m by m.Name) { int num = source.Count <MemberInfo>(); IList <MemberInfo> list3 = source.ToList <MemberInfo>(); if (num == 1) { list2.Add(list3.First <MemberInfo>()); } else { IList <MemberInfo> list4 = new List <MemberInfo>(); foreach (MemberInfo memberInfo in list3) { if (list4.Count == 0) { list4.Add(memberInfo); } else if (!Class_514.IsOverridenGenericMember(memberInfo, bindingAttr) || memberInfo.Name == "Item") { list4.Add(memberInfo); } } list2.AddRange(list4); } } return(list2); }
// Token: 0x060016B7 RID: 5815 RVA: 0x0006B054 File Offset: 0x00069254 private static Class_499.ConvertResult TryConvertInternal(object initialValue, CultureInfo culture, Type targetType, out object value) { if (initialValue == null) { throw new ArgumentNullException("initialValue"); } if (Class_514.IsNullableType(targetType)) { targetType = Nullable.GetUnderlyingType(targetType); } Type type = initialValue.GetType(); if (targetType == type) { value = initialValue; return(Class_499.ConvertResult.Success); } if (Class_499.IsConvertible(initialValue.GetType()) && Class_499.IsConvertible(targetType)) { if (targetType.IsEnum) { if (initialValue is string) { value = Enum.Parse(targetType, initialValue.ToString(), true); return(Class_499.ConvertResult.Success); } if (Class_499.IsInteger(initialValue)) { value = Enum.ToObject(targetType, initialValue); return(Class_499.ConvertResult.Success); } } value = System.Convert.ChangeType(initialValue, targetType, culture); return(Class_499.ConvertResult.Success); } if (initialValue is DateTime && targetType == typeof(DateTimeOffset)) { value = new DateTimeOffset((DateTime)initialValue); return(Class_499.ConvertResult.Success); } if (initialValue is byte[] && targetType == typeof(Guid)) { value = new Guid((byte[])initialValue); return(Class_499.ConvertResult.Success); } if (initialValue is Guid && targetType == typeof(byte[])) { value = ((Guid)initialValue).ToByteArray(); return(Class_499.ConvertResult.Success); } if (initialValue is string) { if (targetType == typeof(Guid)) { value = new Guid((string)initialValue); return(Class_499.ConvertResult.Success); } if (targetType == typeof(Uri)) { value = new Uri((string)initialValue, UriKind.RelativeOrAbsolute); return(Class_499.ConvertResult.Success); } if (targetType == typeof(TimeSpan)) { value = Class_499.ParseTimeSpan((string)initialValue); return(Class_499.ConvertResult.Success); } if (targetType == typeof(byte[])) { value = System.Convert.FromBase64String((string)initialValue); return(Class_499.ConvertResult.Success); } if (typeof(Type).IsAssignableFrom(targetType)) { value = Type.GetType((string)initialValue, true); return(Class_499.ConvertResult.Success); } } if (targetType == typeof(BigInteger)) { value = Class_499.ToBigInteger(initialValue); return(Class_499.ConvertResult.Success); } if (initialValue is BigInteger) { value = Class_499.FromBigInteger((BigInteger)initialValue, targetType); return(Class_499.ConvertResult.Success); } TypeConverter typeConverter = Class_470.GetTypeConverter(type); if (typeConverter != null && typeConverter.CanConvertTo(targetType)) { value = typeConverter.ConvertTo(null, culture, initialValue, targetType); return(Class_499.ConvertResult.Success); } TypeConverter typeConverter2 = Class_470.GetTypeConverter(targetType); if (typeConverter2 != null && typeConverter2.CanConvertFrom(type)) { value = typeConverter2.ConvertFrom(null, culture, initialValue); return(Class_499.ConvertResult.Success); } if (initialValue == DBNull.Value) { if (Class_514.IsNullable(targetType)) { value = Class_499.EnsureTypeAssignable(null, type, targetType); return(Class_499.ConvertResult.Success); } value = null; return(Class_499.ConvertResult.CannotConvertNull); } else { if (initialValue is INullable) { value = Class_499.EnsureTypeAssignable(Class_499.ToValue((INullable)initialValue), type, targetType); return(Class_499.ConvertResult.Success); } if (targetType.IsInterface || targetType.IsGenericTypeDefinition || targetType.IsAbstract) { value = null; return(Class_499.ConvertResult.NotInstantiableType); } value = null; return(Class_499.ConvertResult.NoValidConversion); } }
// Token: 0x06001775 RID: 6005 RVA: 0x0006EE98 File Offset: 0x0006D098 public static bool ImplementsGenericDefinition(Type type, Type genericInterfaceDefinition) { Type type2; return(Class_514.ImplementsGenericDefinition(type, genericInterfaceDefinition, out type2)); }
// Token: 0x06001785 RID: 6021 RVA: 0x0006F676 File Offset: 0x0006D876 public static T GetAttribute <T>(object attributeProvider) where T : Attribute { return(Class_514.GetAttribute <T>(attributeProvider, true)); }
// Token: 0x0600176E RID: 5998 RVA: 0x0006ED91 File Offset: 0x0006CF91 public static bool HasDefaultConstructor(Type t, bool nonPublic) { Class_517.ArgumentNotNull(t, "t"); return(t.IsValueType || Class_514.GetDefaultConstructor(t, nonPublic) != null); }
// Token: 0x0600176F RID: 5999 RVA: 0x0006EDB8 File Offset: 0x0006CFB8 public static ConstructorInfo GetDefaultConstructor(Type t) { return(Class_514.GetDefaultConstructor(t, false)); }
// Token: 0x06001771 RID: 6001 RVA: 0x0006EE0B File Offset: 0x0006D00B public static bool IsNullable(Type t) { Class_517.ArgumentNotNull(t, "t"); return(!t.IsValueType || Class_514.IsNullableType(t)); }
// Token: 0x060016E0 RID: 5856 RVA: 0x0006C110 File Offset: 0x0006A310 private static bool pmethod_4099(object obje_0) { return(obje_0 is T || (obje_0 == null && (!typeof(T).IsValueType || Class_514.IsNullableType(typeof(T))))); }
// Token: 0x06001792 RID: 6034 RVA: 0x0006FC5C File Offset: 0x0006DE5C public static object GetDefaultValue(Type type) { if (!type.IsValueType) { return(null); } Class_496 typeCode = Class_499.GetTypeCode(type); switch (typeCode) { case Class_496.Char: case Class_496.SByte: case Class_496.Int16: case Class_496.UInt16: case Class_496.Int32: case Class_496.Byte: case Class_496.UInt32: return(0); case Class_496.CharNullable: case Class_496.BooleanNullable: case Class_496.SByteNullable: case Class_496.Int16Nullable: case Class_496.UInt16Nullable: case Class_496.Int32Nullable: case Class_496.ByteNullable: case Class_496.UInt32Nullable: case Class_496.Int64Nullable: case Class_496.UInt64Nullable: case Class_496.SingleNullable: case Class_496.DoubleNullable: case Class_496.DateTimeNullable: case Class_496.DateTimeOffsetNullable: case Class_496.DecimalNullable: break; case Class_496.Boolean: return(false); case Class_496.Int64: case Class_496.UInt64: return(0L); case Class_496.Single: return(0f); case Class_496.Double: return(0.0); case Class_496.DateTime: return(default(DateTime)); case Class_496.DateTimeOffset: return(default(DateTimeOffset)); case Class_496.Decimal: return(0m); case Class_496.Guid: return(default(Guid)); default: if (typeCode == Class_496.BigInteger) { return(default(BigInteger)); } break; } if (Class_514.IsNullable(type)) { return(null); } return(Activator.CreateInstance(type)); }
// Token: 0x06001749 RID: 5961 RVA: 0x0006E264 File Offset: 0x0006C464 public static bool IsDictionaryType(Type type) { Class_517.ArgumentNotNull(type, "type"); return(typeof(IDictionary).IsAssignableFrom(type) || Class_514.ImplementsGenericDefinition(type, typeof(IDictionary <, >))); }
// Token: 0x06001693 RID: 5779 RVA: 0x0006A6A4 File Offset: 0x000688A4 public static Class_491 dmethod_4066(Type arg_0, MethodBase arg_1, params string[] strDizi_0) { Class_491 class_ = new Class_491(); Class_480 reflectionDelegateFactory = Class_470.ReflectionDelegateFactory; if (arg_1 != null) { class_.prop_0 = reflectionDelegateFactory.pmethod_4009(arg_1); } else if (Class_514.HasDefaultConstructor(arg_0, false)) { Class_491.NClass_0 nclass_ = new Class_491.NClass_0(); nclass_.field_3 = reflectionDelegateFactory.smethod_4010 <object>(arg_0); class_.prop_0 = new Class_482 <object>(nclass_.nmethod_1); } int i = 0; while (i < strDizi_0.Length) { string text = strDizi_0[i]; MemberInfo[] member = arg_0.GetMember(text, BindingFlags.Instance | BindingFlags.Public); if (member.Length != 1) { throw new ArgumentException("Expected a single member with the name '{0}'.".FormatWith(CultureInfo.InvariantCulture, text)); } MemberInfo memberInfo = member.Single <MemberInfo>(); Class_490 class_2 = new Class_490(); MemberTypes memberType = memberInfo.MemberType; if (memberType == MemberTypes.Field) { goto IL_CE; } if (memberType != MemberTypes.Method) { if (memberType == MemberTypes.Property) { goto IL_CE; } throw new ArgumentException("Unexpected member type '{0}' for member '{1}'.".FormatWith(CultureInfo.InvariantCulture, memberInfo.MemberType, memberInfo.Name)); } else { MethodInfo methodInfo = (MethodInfo)memberInfo; if (methodInfo.IsPublic) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 0 && methodInfo.ReturnType != typeof(void)) { Class_491.NClass_1 nclass_2 = new Class_491.NClass_1(); nclass_2.field_4 = reflectionDelegateFactory.lmethod_4008 <object>(methodInfo); class_2.prop_1 = new Func <object, object>(nclass_2.nmethod_3); } else if (parameters.Length == 1 && methodInfo.ReturnType == typeof(void)) { Class_491.NClass_2 nclass_3 = new Class_491.NClass_2(); nclass_3.field_5 = reflectionDelegateFactory.lmethod_4008 <object>(methodInfo); class_2.prop_2 = new Action <object, object>(nclass_3.nmethod_5); } } } IL_1F9: if (Class_514.CanReadMemberValue(memberInfo, false)) { class_2.prop_1 = reflectionDelegateFactory.dmethod_4006 <object>(memberInfo); } if (Class_514.CanSetMemberValue(memberInfo, false, false)) { class_2.prop_2 = reflectionDelegateFactory.kmethod_4007 <object>(memberInfo); } class_2.prop_0 = Class_514.GetMemberUnderlyingType(memberInfo); class_.prop_1[text] = class_2; i++; continue; IL_CE: if (Class_514.CanReadMemberValue(memberInfo, false)) { class_2.prop_1 = reflectionDelegateFactory.dmethod_4006 <object>(memberInfo); } if (Class_514.CanSetMemberValue(memberInfo, false, false)) { class_2.prop_2 = reflectionDelegateFactory.kmethod_4007 <object>(memberInfo); goto IL_1F9; } goto IL_1F9; } return(class_); }
// Token: 0x06001777 RID: 6007 RVA: 0x0006EF80 File Offset: 0x0006D180 public static bool InheritsGenericDefinition(Type type, Type genericClassDefinition) { Type type2; return(Class_514.InheritsGenericDefinition(type, genericClassDefinition, out type2)); }