Exemple #1
0
        internal IntPtr Box()
        {
            PrimitiveType memberAsPrimitive = (PrimitiveType)_arrayType.MemberType;
            JavaClass     boxClass          = memberAsPrimitive.GetBoxClass();

            IntPtr[] members;
            switch (memberAsPrimitive.Kind)
            {
            case PrimitiveTypeKind.Boolean:
                members = _vm.GetBooleanArray(_arrayPtr).Select(b => boxClass.Box(b, memberAsPrimitive).ToIntPtr()).ToArray();
                break;

            case PrimitiveTypeKind.Byte:
                members = _vm.GetByteArray(_arrayPtr).Select(b => boxClass.Box(b, memberAsPrimitive).ToIntPtr()).ToArray();
                break;

            case PrimitiveTypeKind.Char:
                members = _vm.GetCharArray(_arrayPtr).Select(b => boxClass.Box(b, memberAsPrimitive).ToIntPtr()).ToArray();
                break;

            case PrimitiveTypeKind.Double:
                members = _vm.GetDoubleArray(_arrayPtr).Select(b => boxClass.Box(b, memberAsPrimitive).ToIntPtr()).ToArray();
                break;

            case PrimitiveTypeKind.Float:
                members = _vm.GetFloatArray(_arrayPtr).Select(b => boxClass.Box(b, memberAsPrimitive).ToIntPtr()).ToArray();
                break;

            case PrimitiveTypeKind.Int:
                members = _vm.GetIntArray(_arrayPtr).Select(b => boxClass.Box(b, memberAsPrimitive).ToIntPtr()).ToArray();
                break;

            case PrimitiveTypeKind.Long:
                members = _vm.GetLongArray(_arrayPtr).Select(b => boxClass.Box(b, memberAsPrimitive).ToIntPtr()).ToArray();
                break;

            case PrimitiveTypeKind.Short:
                members = _vm.GetShortArray(_arrayPtr).Select(b => boxClass.Box(b, memberAsPrimitive).ToIntPtr()).ToArray();
                break;

            default: throw new InvalidOperationException("Unknown primitive kind: " + memberAsPrimitive.Kind);
            }
            return(boxClass.NewArray(members));
        }