SetFloatField() public static method

public static SetFloatField ( IntPtr obj, IntPtr fieldID, float val ) : void
obj System.IntPtr
fieldID System.IntPtr
val float
return void
Exemplo n.º 1
0
        protected void _Set <FieldType>(string fieldName, FieldType val)
        {
            IntPtr fieldID = AndroidJNIHelper.GetFieldID <FieldType>(this.m_jclass, fieldName, false);

            if (AndroidReflection.IsPrimitive(typeof(FieldType)))
            {
                if (typeof(FieldType) == typeof(int))
                {
                    AndroidJNISafe.SetIntField(this.m_jobject, fieldID, (int)val);
                }
                else if (typeof(FieldType) == typeof(bool))
                {
                    AndroidJNISafe.SetBooleanField(this.m_jobject, fieldID, (bool)val);
                }
                else if (typeof(FieldType) == typeof(byte))
                {
                    AndroidJNISafe.SetByteField(this.m_jobject, fieldID, (byte)val);
                }
                else if (typeof(FieldType) == typeof(short))
                {
                    AndroidJNISafe.SetShortField(this.m_jobject, fieldID, (short)val);
                }
                else if (typeof(FieldType) == typeof(long))
                {
                    AndroidJNISafe.SetLongField(this.m_jobject, fieldID, (long)val);
                }
                else if (typeof(FieldType) == typeof(float))
                {
                    AndroidJNISafe.SetFloatField(this.m_jobject, fieldID, (float)val);
                }
                else if (typeof(FieldType) == typeof(double))
                {
                    AndroidJNISafe.SetDoubleField(this.m_jobject, fieldID, (double)val);
                }
                else if (typeof(FieldType) == typeof(char))
                {
                    AndroidJNISafe.SetCharField(this.m_jobject, fieldID, (char)val);
                }
            }
            else if (typeof(FieldType) == typeof(string))
            {
                AndroidJNISafe.SetStringField(this.m_jobject, fieldID, (string)val);
            }
            else if (typeof(FieldType) == typeof(AndroidJavaClass))
            {
                AndroidJNISafe.SetObjectField(this.m_jobject, fieldID, ((AndroidJavaClass)val).m_jclass);
            }
            else if (typeof(FieldType) == typeof(AndroidJavaObject))
            {
                AndroidJNISafe.SetObjectField(this.m_jobject, fieldID, ((AndroidJavaObject)val).m_jobject);
            }
            else
            {
                if (!AndroidReflection.IsAssignableFrom(typeof(Array), typeof(FieldType)))
                {
                    throw new Exception("JNI: Unknown field type '" + typeof(FieldType) + "'");
                }
                IntPtr ptr2 = AndroidJNIHelper.ConvertToJNIArray((Array)val);
                AndroidJNISafe.SetObjectField(this.m_jclass, fieldID, ptr2);
            }
        }
Exemplo n.º 2
0
        protected void _Set <FieldType>(string fieldName, FieldType val)
        {
            IntPtr fieldID = AndroidJNIHelper.GetFieldID <FieldType>(this.m_jclass, fieldName, false);
            bool   flag    = AndroidReflection.IsPrimitive(typeof(FieldType));

            if (flag)
            {
                bool flag2 = typeof(FieldType) == typeof(int);
                if (flag2)
                {
                    AndroidJNISafe.SetIntField(this.m_jobject, fieldID, (int)((object)val));
                }
                else
                {
                    bool flag3 = typeof(FieldType) == typeof(bool);
                    if (flag3)
                    {
                        AndroidJNISafe.SetBooleanField(this.m_jobject, fieldID, (bool)((object)val));
                    }
                    else
                    {
                        bool flag4 = typeof(FieldType) == typeof(byte);
                        if (flag4)
                        {
                            Debug.LogWarning("Field type <Byte> for Java set field call is obsolete, use field type <SByte> instead");
                            AndroidJNISafe.SetSByteField(this.m_jobject, fieldID, (sbyte)((byte)((object)val)));
                        }
                        else
                        {
                            bool flag5 = typeof(FieldType) == typeof(sbyte);
                            if (flag5)
                            {
                                AndroidJNISafe.SetSByteField(this.m_jobject, fieldID, (sbyte)((object)val));
                            }
                            else
                            {
                                bool flag6 = typeof(FieldType) == typeof(short);
                                if (flag6)
                                {
                                    AndroidJNISafe.SetShortField(this.m_jobject, fieldID, (short)((object)val));
                                }
                                else
                                {
                                    bool flag7 = typeof(FieldType) == typeof(long);
                                    if (flag7)
                                    {
                                        AndroidJNISafe.SetLongField(this.m_jobject, fieldID, (long)((object)val));
                                    }
                                    else
                                    {
                                        bool flag8 = typeof(FieldType) == typeof(float);
                                        if (flag8)
                                        {
                                            AndroidJNISafe.SetFloatField(this.m_jobject, fieldID, (float)((object)val));
                                        }
                                        else
                                        {
                                            bool flag9 = typeof(FieldType) == typeof(double);
                                            if (flag9)
                                            {
                                                AndroidJNISafe.SetDoubleField(this.m_jobject, fieldID, (double)((object)val));
                                            }
                                            else
                                            {
                                                bool flag10 = typeof(FieldType) == typeof(char);
                                                if (flag10)
                                                {
                                                    AndroidJNISafe.SetCharField(this.m_jobject, fieldID, (char)((object)val));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                bool flag11 = typeof(FieldType) == typeof(string);
                if (flag11)
                {
                    AndroidJNISafe.SetStringField(this.m_jobject, fieldID, (string)((object)val));
                }
                else
                {
                    bool flag12 = typeof(FieldType) == typeof(AndroidJavaClass);
                    if (flag12)
                    {
                        AndroidJNISafe.SetObjectField(this.m_jobject, fieldID, (val == null) ? IntPtr.Zero : ((AndroidJavaClass)((object)val)).m_jclass);
                    }
                    else
                    {
                        bool flag13 = typeof(FieldType) == typeof(AndroidJavaObject);
                        if (flag13)
                        {
                            AndroidJNISafe.SetObjectField(this.m_jobject, fieldID, (val == null) ? IntPtr.Zero : ((AndroidJavaObject)((object)val)).m_jobject);
                        }
                        else
                        {
                            bool flag14 = AndroidReflection.IsAssignableFrom(typeof(Array), typeof(FieldType));
                            if (!flag14)
                            {
                                string arg_3B5_0 = "JNI: Unknown field type '";
                                Type   expr_3A4  = typeof(FieldType);
                                throw new Exception(arg_3B5_0 + ((expr_3A4 != null) ? expr_3A4.ToString() : null) + "'");
                            }
                            IntPtr val2 = AndroidJNIHelper.ConvertToJNIArray((Array)((object)val));
                            AndroidJNISafe.SetObjectField(this.m_jclass, fieldID, val2);
                        }
                    }
                }
            }
        }