GetStringField() public static method

public static GetStringField ( IntPtr obj, IntPtr fieldID ) : string
obj System.IntPtr
fieldID System.IntPtr
return string
Example #1
0
        protected FieldType _Get <FieldType>(string fieldName)
        {
            IntPtr fieldID = AndroidJNIHelper.GetFieldID <FieldType>(this.m_jclass, fieldName, false);

            if (AndroidReflection.IsPrimitive(typeof(FieldType)))
            {
                if (typeof(FieldType) == typeof(int))
                {
                    return((FieldType)AndroidJNISafe.GetIntField(this.m_jobject, fieldID));
                }
                if (typeof(FieldType) == typeof(bool))
                {
                    return((FieldType)AndroidJNISafe.GetBooleanField(this.m_jobject, fieldID));
                }
                if (typeof(FieldType) == typeof(byte))
                {
                    return((FieldType)AndroidJNISafe.GetByteField(this.m_jobject, fieldID));
                }
                if (typeof(FieldType) == typeof(short))
                {
                    return((FieldType)AndroidJNISafe.GetShortField(this.m_jobject, fieldID));
                }
                if (typeof(FieldType) == typeof(long))
                {
                    return((FieldType)AndroidJNISafe.GetLongField(this.m_jobject, fieldID));
                }
                if (typeof(FieldType) == typeof(float))
                {
                    return((FieldType)AndroidJNISafe.GetFloatField(this.m_jobject, fieldID));
                }
                if (typeof(FieldType) == typeof(double))
                {
                    return((FieldType)AndroidJNISafe.GetDoubleField(this.m_jobject, fieldID));
                }
                if (typeof(FieldType) == typeof(char))
                {
                    return((FieldType)AndroidJNISafe.GetCharField(this.m_jobject, fieldID));
                }
                return(default(FieldType));
            }
            if (typeof(FieldType) == typeof(string))
            {
                return((FieldType)AndroidJNISafe.GetStringField(this.m_jobject, fieldID));
            }
            if (typeof(FieldType) == typeof(AndroidJavaClass))
            {
                return((FieldType)AndroidJavaClassDeleteLocalRef(AndroidJNISafe.GetObjectField(this.m_jobject, fieldID)));
            }
            if (typeof(FieldType) == typeof(AndroidJavaObject))
            {
                return((FieldType)AndroidJavaObjectDeleteLocalRef(AndroidJNISafe.GetObjectField(this.m_jobject, fieldID)));
            }
            if (!AndroidReflection.IsAssignableFrom(typeof(Array), typeof(FieldType)))
            {
                throw new Exception("JNI: Unknown field type '" + typeof(FieldType) + "'");
            }
            return(AndroidJNIHelper.ConvertFromJNIArray <FieldType>(AndroidJNISafe.GetObjectField(this.m_jobject, fieldID)));
        }
Example #2
0
        protected FieldType _Get <FieldType>(string fieldName)
        {
            IntPtr    fieldID = AndroidJNIHelper.GetFieldID <FieldType>(this.m_jclass, fieldName, false);
            bool      flag    = AndroidReflection.IsPrimitive(typeof(FieldType));
            FieldType result;

            if (flag)
            {
                bool flag2 = typeof(FieldType) == typeof(int);
                if (flag2)
                {
                    result = (FieldType)((object)AndroidJNISafe.GetIntField(this.m_jobject, fieldID));
                }
                else
                {
                    bool flag3 = typeof(FieldType) == typeof(bool);
                    if (flag3)
                    {
                        result = (FieldType)((object)AndroidJNISafe.GetBooleanField(this.m_jobject, 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.GetSByteField(this.m_jobject, fieldID)));
                        }
                        else
                        {
                            bool flag5 = typeof(FieldType) == typeof(sbyte);
                            if (flag5)
                            {
                                result = (FieldType)((object)AndroidJNISafe.GetSByteField(this.m_jobject, fieldID));
                            }
                            else
                            {
                                bool flag6 = typeof(FieldType) == typeof(short);
                                if (flag6)
                                {
                                    result = (FieldType)((object)AndroidJNISafe.GetShortField(this.m_jobject, fieldID));
                                }
                                else
                                {
                                    bool flag7 = typeof(FieldType) == typeof(long);
                                    if (flag7)
                                    {
                                        result = (FieldType)((object)AndroidJNISafe.GetLongField(this.m_jobject, fieldID));
                                    }
                                    else
                                    {
                                        bool flag8 = typeof(FieldType) == typeof(float);
                                        if (flag8)
                                        {
                                            result = (FieldType)((object)AndroidJNISafe.GetFloatField(this.m_jobject, fieldID));
                                        }
                                        else
                                        {
                                            bool flag9 = typeof(FieldType) == typeof(double);
                                            if (flag9)
                                            {
                                                result = (FieldType)((object)AndroidJNISafe.GetDoubleField(this.m_jobject, fieldID));
                                            }
                                            else
                                            {
                                                bool flag10 = typeof(FieldType) == typeof(char);
                                                if (flag10)
                                                {
                                                    result = (FieldType)((object)AndroidJNISafe.GetCharField(this.m_jobject, fieldID));
                                                }
                                                else
                                                {
                                                    result = default(FieldType);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                bool flag11 = typeof(FieldType) == typeof(string);
                if (flag11)
                {
                    result = (FieldType)((object)AndroidJNISafe.GetStringField(this.m_jobject, fieldID));
                }
                else
                {
                    bool flag12 = typeof(FieldType) == typeof(AndroidJavaClass);
                    if (flag12)
                    {
                        IntPtr objectField = AndroidJNISafe.GetObjectField(this.m_jobject, fieldID);
                        result = ((objectField == IntPtr.Zero) ? default(FieldType) : ((FieldType)((object)AndroidJavaObject.AndroidJavaClassDeleteLocalRef(objectField))));
                    }
                    else
                    {
                        bool flag13 = typeof(FieldType) == typeof(AndroidJavaObject);
                        if (flag13)
                        {
                            IntPtr objectField2 = AndroidJNISafe.GetObjectField(this.m_jobject, fieldID);
                            result = ((objectField2 == IntPtr.Zero) ? default(FieldType) : ((FieldType)((object)AndroidJavaObject.AndroidJavaObjectDeleteLocalRef(objectField2))));
                        }
                        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 objectField3 = AndroidJNISafe.GetObjectField(this.m_jobject, fieldID);
                            result = ((objectField3 == IntPtr.Zero) ? default(FieldType) : ((FieldType)((object)AndroidJNIHelper.ConvertFromJNIArray <FieldType>(objectField3))));
                        }
                    }
                }
            }
            return(result);
        }