Beispiel #1
0
        // Token: 0x060014DA RID: 5338 RVA: 0x000607DC File Offset: 0x0005E9DC
        private string vmethod_3815(Type arg_0)
        {
            Class_316 cachedAttribute = Class_470.GetCachedAttribute <Class_316>(arg_0);

            if (cachedAttribute != null && !string.IsNullOrEmpty(cachedAttribute.prop_1))
            {
                return(cachedAttribute.prop_1);
            }
            return(null);
        }
Beispiel #2
0
        // Token: 0x060014DB RID: 5339 RVA: 0x00060810 File Offset: 0x0005EA10
        private string dmethod_3816(Type arg_0)
        {
            Class_316 cachedAttribute = Class_470.GetCachedAttribute <Class_316>(arg_0);

            if (cachedAttribute != null && !string.IsNullOrEmpty(cachedAttribute.prop_2))
            {
                return(cachedAttribute.prop_2);
            }
            DescriptionAttribute attribute = Class_514.GetAttribute <DescriptionAttribute>(arg_0);

            if (attribute != null)
            {
                return(attribute.Description);
            }
            return(null);
        }
Beispiel #3
0
        // Token: 0x060014DC RID: 5340 RVA: 0x00060858 File Offset: 0x0005EA58
        private string kmethod_3817(Type arg_0, bool bool_0)
        {
            Class_316 cachedAttribute = Class_470.GetCachedAttribute <Class_316>(arg_0);

            if (cachedAttribute != null && !string.IsNullOrEmpty(cachedAttribute.prop_0))
            {
                return(cachedAttribute.prop_0);
            }
            if (bool_0)
            {
                return(null);
            }
            switch (this.prop_0)
            {
            case Class_437.UseTypeName:
                return(arg_0.FullName);

            case Class_437.UseAssemblyQualifiedName:
                return(arg_0.AssemblyQualifiedName);

            default:
                return(null);
            }
        }
Beispiel #4
0
        // Token: 0x060014DD RID: 5341 RVA: 0x000608BC File Offset: 0x0005EABC
        private Class_459 lmethod_3818(Type arg_0, Class_364 arg_1, bool bool_0)
        {
            Class_462.NClass_1 nclass_ = new Class_462.NClass_1();
            nclass_.field_7 = arg_0;
            Class_517.ArgumentNotNull(nclass_.field_7, "type");
            string text  = this.kmethod_3817(nclass_.field_7, false);
            string text2 = this.kmethod_3817(nclass_.field_7, true);

            if (!string.IsNullOrEmpty(text))
            {
                Class_459 class_ = this.field_1.xmethod_3531(text);
                if (class_ != null)
                {
                    if (arg_1 != Class_364.Always && !Class_462.gmethod_3823(class_.prop_7, Class_463.Null))
                    {
                        class_.prop_7 |= Class_463.Null;
                    }
                    if (bool_0 && class_.prop_2 != true)
                    {
                        class_.prop_2 = new bool?(true);
                    }
                    return(class_);
                }
            }
            if (this.field_2.Any(new Func <Class_462.NClass_0, bool>(nclass_.nmethod_6)))
            {
                throw new Class_318("Unresolved circular reference for type '{0}'. Explicitly define an Id for the type using a JsonObject/JsonArray attribute or automatically generate a type Id using the UndefinedSchemaIdHandling property.".FormatWith(CultureInfo.InvariantCulture, nclass_.field_7));
            }
            Class_349 class_2 = this.prop_1.tmethod_3542(nclass_.field_7);
            Class_299 class_3;

            if ((class_3 = class_2.prop_3) != null || (class_3 = class_2.prop_4) != null)
            {
                Class_459 class_4 = class_3.vmethod_2135();
                if (class_4 != null)
                {
                    return(class_4);
                }
            }
            this.pmethod_3809(new Class_462.NClass_0(nclass_.field_7, new Class_459()));
            if (text2 != null)
            {
                this.prop_2.prop_0 = text2;
            }
            if (bool_0)
            {
                this.prop_2.prop_2 = new bool?(true);
            }
            this.prop_2.prop_1 = this.vmethod_3815(nclass_.field_7);
            this.prop_2.prop_6 = this.dmethod_3816(nclass_.field_7);
            if (class_3 != null)
            {
                this.prop_2.prop_7 = new Class_463?(Class_463.Any);
            }
            else
            {
                switch (class_2.field_5)
                {
                case Class_448.Object:
                    this.prop_2.prop_7 = new Class_463?(this.pmethod_3819(Class_463.Object, arg_1));
                    this.prop_2.prop_0 = this.kmethod_3817(nclass_.field_7, false);
                    this.xmethod_3821(nclass_.field_7, (Class_464)class_2);
                    goto IL_519;

                case Class_448.Array:
                    {
                        this.prop_2.prop_7 = new Class_463?(this.pmethod_3819(Class_463.Array, arg_1));
                        this.prop_2.prop_0 = this.kmethod_3817(nclass_.field_7, false);
                        Class_376 cachedAttribute    = Class_470.GetCachedAttribute <Class_376>(nclass_.field_7);
                        bool      flag               = cachedAttribute == null || cachedAttribute.AllowNullItems;
                        Type      collectionItemType = Class_514.GetCollectionItemType(nclass_.field_7);
                        if (collectionItemType != null)
                        {
                            this.prop_2.prop_18 = new List <Class_459>();
                            this.prop_2.prop_18.Add(this.lmethod_3818(collectionItemType, (!flag) ? Class_364.Always : Class_364.Default, false));
                            goto IL_519;
                        }
                        goto IL_519;
                    }

                case Class_448.Primitive:
                {
                    this.prop_2.prop_7 = new Class_463?(this.cmethod_3824(nclass_.field_7, arg_1));
                    if (!(this.prop_2.prop_7 == Class_463.Integer) || !nclass_.field_7.IsEnum || nclass_.field_7.IsDefined(typeof(FlagsAttribute), true))
                    {
                        goto IL_519;
                    }
                    this.prop_2.prop_28 = new List <Class_361>();
                    IList <Class_506 <long> > namesAndValues = Class_505.GetNamesAndValues <long>(nclass_.field_7);
                    using (IEnumerator <Class_506 <long> > enumerator = namesAndValues.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Class_506 <long> class_5 = enumerator.Current;
                            Class_361        item    = Class_361.smethod_2560(class_5.Value);
                            this.prop_2.prop_28.Add(item);
                        }
                        goto IL_519;
                    }
                    break;
                }

                case Class_448.String:
                    break;

                case Class_448.Dictionary:
                {
                    this.prop_2.prop_7 = new Class_463?(this.pmethod_3819(Class_463.Object, arg_1));
                    Type type;
                    Type arg_2;
                    Class_514.GetDictionaryKeyValueTypes(nclass_.field_7, out type, out arg_2);
                    if (!(type != null))
                    {
                        goto IL_519;
                    }
                    Class_349 class_6 = this.prop_1.tmethod_3542(type);
                    if (class_6.field_5 == Class_448.Primitive)
                    {
                        this.prop_2.prop_24 = this.lmethod_3818(arg_2, Class_364.Default, false);
                        goto IL_519;
                    }
                    goto IL_519;
                }

                case Class_448.Dynamic:
                case Class_448.Linq:
                    this.prop_2.prop_7 = new Class_463?(Class_463.Any);
                    goto IL_519;

                case Class_448.Serializable:
                    this.prop_2.prop_7 = new Class_463?(this.pmethod_3819(Class_463.Object, arg_1));
                    this.prop_2.prop_0 = this.kmethod_3817(nclass_.field_7, false);
                    this.tmethod_3822(nclass_.field_7, (Class_367)class_2);
                    goto IL_519;

                default:
                    throw new Class_318("Unexpected contract type: {0}".FormatWith(CultureInfo.InvariantCulture, class_2));
                }
                Class_463 value = (!Class_514.IsNullable(class_2.prop_0)) ? Class_463.String : this.pmethod_3819(Class_463.String, arg_1);
                this.prop_2.prop_7 = new Class_463?(value);
            }
            IL_519:
            return(this.smethod_3810().nprop_1);
        }
Beispiel #5
0
        // 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);
            }
        }