private static void InternalSetConstant(FieldInfo fi, JavaArchiveReflectorFieldInfo yi) { // X:\jsc.svn\examples\java\Test\TestJavaFinalIntegerField\TestJavaFinalIntegerField\Program.cs var RawConstantValue = fi.GetRawConstantValue(); if (RawConstantValue == null) { // wtf? //001b ScriptCoreLibAndroid.Natives android.os.Parcelable //System.InvalidOperationException: SetConstant { FieldName = EMPTY_STATE, FieldType = android.view.AbsSavedState } yi.IsLiteral = false; // enum? return; } var RawConstantValueType = RawConstantValue.GetType(); if (RawConstantValueType == typeof(int)) { yi.LiteralInt32 = (int)RawConstantValue; } else if (RawConstantValueType == typeof(short)) { yi.LiteralInt16 = (short)RawConstantValue; } else if (RawConstantValueType == typeof(long)) { yi.LiteralInt64 = (long)RawConstantValue; } else if (RawConstantValueType == typeof(sbyte)) { yi.LiteralInt8 = (byte)(sbyte)RawConstantValue; } else if (fi.FieldType == typeof(string)) { yi.LiteralString = (string)RawConstantValue; } else { //Console.WriteLine( //"InternalSetConstant " + new { fi.DeclaringType.FullName, fi.Name, RawConstantValueType, fi.FieldType } // ); yi.IsLiteral = false; } //throw new InvalidOperationException( //); }
public JavaArchiveReflectorFieldInfo[] Type_GetFields(string TypeName) { var y = default(JavaArchiveReflectorFieldInfo[]); var f = default(System.Reflection.FieldInfo[]); var t = this.clazzLoader.GetType(TypeName); try { f = t.GetFields(); // what about protected members? } catch { System.Console.WriteLine("JavaArchiveReflector.Type_GetFields error, TypeName: " + TypeName); // we did not find a type. skip constructors.. y = new JavaArchiveReflectorFieldInfo[0]; } if (y == null) { y = new JavaArchiveReflectorFieldInfo[f.Length]; for (int i = 0; i < f.Length; i++) { var fi = f[i]; var yi = new JavaArchiveReflectorFieldInfo { FieldName = fi.Name, FieldType = fi.FieldType.FullName, IsPublic = fi.IsPublic, IsPrivate = fi.IsPrivate, IsStatic = fi.IsStatic, IsFamily = fi.IsFamily, IsLiteral = fi.IsLiteral, }; if (fi.IsLiteral) { InternalSetConstant(fi, yi); } y[i] = yi; } } return(y); }
private static void InternalSetConstant(FieldInfo fi, JavaArchiveReflectorFieldInfo yi) { // X:\jsc.svn\examples\java\Test\TestJavaFinalIntegerField\TestJavaFinalIntegerField\Program.cs var RawConstantValue = fi.GetRawConstantValue(); if (RawConstantValue == null) { // wtf? //001b ScriptCoreLibAndroid.Natives android.os.Parcelable //System.InvalidOperationException: SetConstant { FieldName = EMPTY_STATE, FieldType = android.view.AbsSavedState } yi.IsLiteral = false; // enum? return; } var RawConstantValueType = RawConstantValue.GetType(); if (RawConstantValueType == typeof(int)) yi.LiteralInt32 = (int)RawConstantValue; else if (RawConstantValueType == typeof(short)) yi.LiteralInt16 = (short)RawConstantValue; else if (RawConstantValueType == typeof(long)) yi.LiteralInt64 = (long)RawConstantValue; else if (RawConstantValueType == typeof(sbyte)) yi.LiteralInt8 = (byte)(sbyte)RawConstantValue; else if (fi.FieldType == typeof(string)) yi.LiteralString = (string)RawConstantValue; else { //Console.WriteLine( //"InternalSetConstant " + new { fi.DeclaringType.FullName, fi.Name, RawConstantValueType, fi.FieldType } // ); yi.IsLiteral = false; } //throw new InvalidOperationException( //); }
public JavaArchiveReflectorFieldInfo[] Type_GetFields(string TypeName) { var y = default(JavaArchiveReflectorFieldInfo[]); var f = default(System.Reflection.FieldInfo[]); var t = this.clazzLoader.GetType(TypeName); try { f = t.GetFields(); // what about protected members? } catch { System.Console.WriteLine("JavaArchiveReflector.Type_GetFields error, TypeName: " + TypeName); // we did not find a type. skip constructors.. y = new JavaArchiveReflectorFieldInfo[0]; } if (y == null) { y = new JavaArchiveReflectorFieldInfo[f.Length]; for (int i = 0; i < f.Length; i++) { var fi = f[i]; var yi = new JavaArchiveReflectorFieldInfo { FieldName = fi.Name, FieldType = fi.FieldType.FullName, IsPublic = fi.IsPublic, IsPrivate = fi.IsPrivate, IsStatic = fi.IsStatic, IsFamily = fi.IsFamily, IsLiteral = fi.IsLiteral, }; if (fi.IsLiteral) { InternalSetConstant(fi, yi); } y[i] = yi; } } return y; }