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)(object)val); } else if (typeof(FieldType) == typeof(bool)) { AndroidJNISafe.SetBooleanField(this.m_jobject, fieldId, (bool)(object)val); } else if (typeof(FieldType) == typeof(byte)) { AndroidJNISafe.SetByteField(this.m_jobject, fieldId, (byte)(object)val); } else if (typeof(FieldType) == typeof(short)) { AndroidJNISafe.SetShortField(this.m_jobject, fieldId, (short)(object)val); } else if (typeof(FieldType) == typeof(long)) { AndroidJNISafe.SetLongField(this.m_jobject, fieldId, (long)(object)val); } else if (typeof(FieldType) == typeof(float)) { AndroidJNISafe.SetFloatField(this.m_jobject, fieldId, (float)(object)val); } else if (typeof(FieldType) == typeof(double)) { AndroidJNISafe.SetDoubleField(this.m_jobject, fieldId, (double)(object)val); } else { if (typeof(FieldType) != typeof(char)) { return; } AndroidJNISafe.SetCharField(this.m_jobject, fieldId, (char)(object)val); } } else if (typeof(FieldType) == typeof(string)) { AndroidJNISafe.SetStringField(this.m_jobject, fieldId, (string)(object)val); } else if (typeof(FieldType) == typeof(AndroidJavaClass)) { AndroidJNISafe.SetObjectField(this.m_jobject, fieldId, ((AndroidJavaObject)(object)val).m_jclass); } else if (typeof(FieldType) == typeof(AndroidJavaObject)) { AndroidJNISafe.SetObjectField(this.m_jobject, fieldId, ((AndroidJavaObject)(object)val).m_jobject); } else { if (!AndroidReflection.IsAssignableFrom(typeof(Array), typeof(FieldType))) { throw new Exception("JNI: Unknown field type '" + (object)typeof(FieldType) + "'"); } IntPtr jniArray = AndroidJNIHelper.ConvertToJNIArray((Array)(object)val); AndroidJNISafe.SetObjectField(this.m_jclass, fieldId, jniArray); } }
protected void _SetStatic <FieldType>(string fieldName, FieldType val) { IntPtr fieldID = AndroidJNIHelper.GetFieldID <FieldType>(this.m_jclass, fieldName, true); if (AndroidReflection.IsPrimitive(typeof(FieldType))) { if (typeof(FieldType) == typeof(int)) { AndroidJNISafe.SetStaticIntField(this.m_jclass, fieldID, (int)val); } else if (typeof(FieldType) == typeof(bool)) { AndroidJNISafe.SetStaticBooleanField(this.m_jclass, fieldID, (bool)val); } else if (typeof(FieldType) == typeof(byte)) { AndroidJNISafe.SetStaticByteField(this.m_jclass, fieldID, (byte)val); } else if (typeof(FieldType) == typeof(short)) { AndroidJNISafe.SetStaticShortField(this.m_jclass, fieldID, (short)val); } else if (typeof(FieldType) == typeof(long)) { AndroidJNISafe.SetStaticLongField(this.m_jclass, fieldID, (long)val); } else if (typeof(FieldType) == typeof(float)) { AndroidJNISafe.SetStaticFloatField(this.m_jclass, fieldID, (float)val); } else if (typeof(FieldType) == typeof(double)) { AndroidJNISafe.SetStaticDoubleField(this.m_jclass, fieldID, (double)val); } else if (typeof(FieldType) == typeof(char)) { AndroidJNISafe.SetStaticCharField(this.m_jclass, fieldID, (char)val); } } else if (typeof(FieldType) == typeof(string)) { AndroidJNISafe.SetStaticStringField(this.m_jclass, fieldID, (string)val); } else if (typeof(FieldType) == typeof(AndroidJavaClass)) { AndroidJNISafe.SetStaticObjectField(this.m_jclass, fieldID, ((AndroidJavaClass)val).m_jclass); } else if (typeof(FieldType) == typeof(AndroidJavaObject)) { AndroidJNISafe.SetStaticObjectField(this.m_jclass, 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.SetStaticObjectField(this.m_jclass, fieldID, ptr2); } }
protected void _SetStatic <FieldType>(string fieldName, FieldType val) { IntPtr fieldID = AndroidJNIHelper.GetFieldID <FieldType>(this.m_jclass, fieldName, true); bool flag = AndroidReflection.IsPrimitive(typeof(FieldType)); if (flag) { bool flag2 = typeof(FieldType) == typeof(int); if (flag2) { AndroidJNISafe.SetStaticIntField(this.m_jclass, fieldID, (int)((object)val)); } else { bool flag3 = typeof(FieldType) == typeof(bool); if (flag3) { AndroidJNISafe.SetStaticBooleanField(this.m_jclass, 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.SetStaticSByteField(this.m_jclass, fieldID, (sbyte)((byte)((object)val))); } else { bool flag5 = typeof(FieldType) == typeof(sbyte); if (flag5) { AndroidJNISafe.SetStaticSByteField(this.m_jclass, fieldID, (sbyte)((object)val)); } else { bool flag6 = typeof(FieldType) == typeof(short); if (flag6) { AndroidJNISafe.SetStaticShortField(this.m_jclass, fieldID, (short)((object)val)); } else { bool flag7 = typeof(FieldType) == typeof(long); if (flag7) { AndroidJNISafe.SetStaticLongField(this.m_jclass, fieldID, (long)((object)val)); } else { bool flag8 = typeof(FieldType) == typeof(float); if (flag8) { AndroidJNISafe.SetStaticFloatField(this.m_jclass, fieldID, (float)((object)val)); } else { bool flag9 = typeof(FieldType) == typeof(double); if (flag9) { AndroidJNISafe.SetStaticDoubleField(this.m_jclass, fieldID, (double)((object)val)); } else { bool flag10 = typeof(FieldType) == typeof(char); if (flag10) { AndroidJNISafe.SetStaticCharField(this.m_jclass, fieldID, (char)((object)val)); } } } } } } } } } } else { bool flag11 = typeof(FieldType) == typeof(string); if (flag11) { AndroidJNISafe.SetStaticStringField(this.m_jclass, fieldID, (string)((object)val)); } else { bool flag12 = typeof(FieldType) == typeof(AndroidJavaClass); if (flag12) { AndroidJNISafe.SetStaticObjectField(this.m_jclass, fieldID, (val == null) ? IntPtr.Zero : ((AndroidJavaClass)((object)val)).m_jclass); } else { bool flag13 = typeof(FieldType) == typeof(AndroidJavaObject); if (flag13) { AndroidJNISafe.SetStaticObjectField(this.m_jclass, 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.SetStaticObjectField(this.m_jclass, fieldID, val2); } } } } }