GetStaticCharField() public static method

public static GetStaticCharField ( IntPtr clazz, IntPtr fieldID ) : char
clazz System.IntPtr
fieldID System.IntPtr
return char
Ejemplo n.º 1
0
        protected FieldType _GetStatic <FieldType>(string fieldName)
        {
            IntPtr fieldID = AndroidJNIHelper.GetFieldID <FieldType>(this.m_jclass, fieldName, true);

            if (AndroidReflection.IsPrimitive(typeof(FieldType)))
            {
                if (typeof(FieldType) == typeof(int))
                {
                    return((FieldType)AndroidJNISafe.GetStaticIntField(this.m_jclass, fieldID));
                }
                if (typeof(FieldType) == typeof(bool))
                {
                    return((FieldType)AndroidJNISafe.GetStaticBooleanField(this.m_jclass, fieldID));
                }
                if (typeof(FieldType) == typeof(byte))
                {
                    return((FieldType)AndroidJNISafe.GetStaticByteField(this.m_jclass, fieldID));
                }
                if (typeof(FieldType) == typeof(short))
                {
                    return((FieldType)AndroidJNISafe.GetStaticShortField(this.m_jclass, fieldID));
                }
                if (typeof(FieldType) == typeof(long))
                {
                    return((FieldType)AndroidJNISafe.GetStaticLongField(this.m_jclass, fieldID));
                }
                if (typeof(FieldType) == typeof(float))
                {
                    return((FieldType)AndroidJNISafe.GetStaticFloatField(this.m_jclass, fieldID));
                }
                if (typeof(FieldType) == typeof(double))
                {
                    return((FieldType)AndroidJNISafe.GetStaticDoubleField(this.m_jclass, fieldID));
                }
                if (typeof(FieldType) == typeof(char))
                {
                    return((FieldType)AndroidJNISafe.GetStaticCharField(this.m_jclass, fieldID));
                }
                return(default(FieldType));
            }
            if (typeof(FieldType) == typeof(string))
            {
                return((FieldType)AndroidJNISafe.GetStaticStringField(this.m_jclass, fieldID));
            }
            if (typeof(FieldType) == typeof(AndroidJavaClass))
            {
                return((FieldType)AndroidJavaClassDeleteLocalRef(AndroidJNISafe.GetStaticObjectField(this.m_jclass, fieldID)));
            }
            if (typeof(FieldType) == typeof(AndroidJavaObject))
            {
                return((FieldType)AndroidJavaObjectDeleteLocalRef(AndroidJNISafe.GetStaticObjectField(this.m_jclass, fieldID)));
            }
            if (!AndroidReflection.IsAssignableFrom(typeof(Array), typeof(FieldType)))
            {
                throw new Exception("JNI: Unknown field type '" + typeof(FieldType) + "'");
            }
            return(AndroidJNIHelper.ConvertFromJNIArray <FieldType>(AndroidJNISafe.GetStaticObjectField(this.m_jclass, fieldID)));
        }
Ejemplo n.º 2
0
        protected FieldType _GetStatic <FieldType>(string fieldName)
        {
            IntPtr    fieldID = AndroidJNIHelper.GetFieldID <FieldType>(this.m_jclass, fieldName, true);
            bool      flag    = AndroidReflection.IsPrimitive(typeof(FieldType));
            FieldType result;

            if (flag)
            {
                bool flag2 = typeof(FieldType) == typeof(int);
                if (flag2)
                {
                    result = (FieldType)((object)AndroidJNISafe.GetStaticIntField(this.m_jclass, fieldID));
                }
                else
                {
                    bool flag3 = typeof(FieldType) == typeof(bool);
                    if (flag3)
                    {
                        result = (FieldType)((object)AndroidJNISafe.GetStaticBooleanField(this.m_jclass, fieldID));
                    }
                    else
                    {
                        bool flag4 = typeof(FieldType) == typeof(byte);
                        if (flag4)
                        {
                            Debug.LogWarning("Field type <Byte> for Java get field call is obsolete, use field type <SByte> instead");
                            result = (FieldType)((object)((byte)AndroidJNISafe.GetStaticSByteField(this.m_jclass, fieldID)));
                        }
                        else
                        {
                            bool flag5 = typeof(FieldType) == typeof(sbyte);
                            if (flag5)
                            {
                                result = (FieldType)((object)AndroidJNISafe.GetStaticSByteField(this.m_jclass, fieldID));
                            }
                            else
                            {
                                bool flag6 = typeof(FieldType) == typeof(short);
                                if (flag6)
                                {
                                    result = (FieldType)((object)AndroidJNISafe.GetStaticShortField(this.m_jclass, fieldID));
                                }
                                else
                                {
                                    bool flag7 = typeof(FieldType) == typeof(long);
                                    if (flag7)
                                    {
                                        result = (FieldType)((object)AndroidJNISafe.GetStaticLongField(this.m_jclass, fieldID));
                                    }
                                    else
                                    {
                                        bool flag8 = typeof(FieldType) == typeof(float);
                                        if (flag8)
                                        {
                                            result = (FieldType)((object)AndroidJNISafe.GetStaticFloatField(this.m_jclass, fieldID));
                                        }
                                        else
                                        {
                                            bool flag9 = typeof(FieldType) == typeof(double);
                                            if (flag9)
                                            {
                                                result = (FieldType)((object)AndroidJNISafe.GetStaticDoubleField(this.m_jclass, fieldID));
                                            }
                                            else
                                            {
                                                bool flag10 = typeof(FieldType) == typeof(char);
                                                if (flag10)
                                                {
                                                    result = (FieldType)((object)AndroidJNISafe.GetStaticCharField(this.m_jclass, fieldID));
                                                }
                                                else
                                                {
                                                    result = default(FieldType);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                bool flag11 = typeof(FieldType) == typeof(string);
                if (flag11)
                {
                    result = (FieldType)((object)AndroidJNISafe.GetStaticStringField(this.m_jclass, fieldID));
                }
                else
                {
                    bool flag12 = typeof(FieldType) == typeof(AndroidJavaClass);
                    if (flag12)
                    {
                        IntPtr staticObjectField = AndroidJNISafe.GetStaticObjectField(this.m_jclass, fieldID);
                        result = ((staticObjectField == IntPtr.Zero) ? default(FieldType) : ((FieldType)((object)AndroidJavaObject.AndroidJavaClassDeleteLocalRef(staticObjectField))));
                    }
                    else
                    {
                        bool flag13 = typeof(FieldType) == typeof(AndroidJavaObject);
                        if (flag13)
                        {
                            IntPtr staticObjectField2 = AndroidJNISafe.GetStaticObjectField(this.m_jclass, fieldID);
                            result = ((staticObjectField2 == IntPtr.Zero) ? default(FieldType) : ((FieldType)((object)AndroidJavaObject.AndroidJavaObjectDeleteLocalRef(staticObjectField2))));
                        }
                        else
                        {
                            bool flag14 = AndroidReflection.IsAssignableFrom(typeof(Array), typeof(FieldType));
                            if (!flag14)
                            {
                                string arg_3D3_0 = "JNI: Unknown field type '";
                                Type   expr_3C2  = typeof(FieldType);
                                throw new Exception(arg_3D3_0 + ((expr_3C2 != null) ? expr_3C2.ToString() : null) + "'");
                            }
                            IntPtr staticObjectField3 = AndroidJNISafe.GetStaticObjectField(this.m_jclass, fieldID);
                            result = ((staticObjectField3 == IntPtr.Zero) ? default(FieldType) : ((FieldType)((object)AndroidJNIHelper.ConvertFromJNIArray <FieldType>(staticObjectField3))));
                        }
                    }
                }
            }
            return(result);
        }