Ejemplo n.º 1
0
        /// <summary>
        /// Gets a readable version of the result code as an ASCII string.
        /// </summary>
        /// <param name="resultCode">The MLResult that should be converted.</param>
        /// <returns>ASCII string containing a readable version of the result code.</returns>
        public static string GetResultString(MLResult.Code resultCode)
        {
            string finalResult = "MLNetworking.GetResultString failed due to internal error";

            try
            {
                finalResult = Marshal.PtrToStringAnsi(MLNetworkingNativeBindings.MLNetworkingGetResultString(resultCode));
            }
            catch (System.DllNotFoundException)
            {
                MLPluginLog.Error("MLNetworking API is currently available only on device.");
                finalResult = "MLNetworking API is currently available only on device.";
            }
            catch (System.EntryPointNotFoundException)
            {
                MLPluginLog.Error("MLNetworking API symbols not found");
                finalResult = "MLNetworking API symbols not found";
            }

            return(finalResult);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Provides the string value for any MLResult.Code.
        /// </summary>
        /// <param name="resultCode">The code to convert into a string value.</param>
        /// <returns>The string value of the given MLResult.Code.</returns>
        public static string CodeToString(MLResult.Code resultCode)
        {
            string codeString = string.Empty;

            switch ((CodePrefix)((int)resultCode >> 16))
            {
            case CodePrefix.MLResultGlobal:
            case CodePrefix.MLSnapshotResult:
                codeString = Marshal.PtrToStringAnsi(MagicLeapNativeBindings.MLSnapshotGetResultString(resultCode));
                break;

            case CodePrefix.MLAudioResult:
                codeString = Marshal.PtrToStringAnsi(MLAudio.GetResultString(resultCode));
                break;

            case CodePrefix.MLMediaDRMResult:
            case CodePrefix.MLMediaGenericResult:
            case CodePrefix.MLMediaPlayerResult:
            case CodePrefix.MLMediaResult:
                codeString = Marshal.PtrToStringAnsi(MLMediaPlayer.GetResultString(resultCode));
                break;

            case CodePrefix.MLDispatchResult:
                codeString = Marshal.PtrToStringAnsi(MLDispatch.GetResultString(resultCode));
                break;

            case CodePrefix.MLIdentityResult:
                codeString = Marshal.PtrToStringAnsi(MLIdentity.GetResultString(resultCode));
                break;

            case CodePrefix.MLPassableWorldResult:
                codeString = Marshal.PtrToStringAnsi(MLPersistentCoordinateFrames.GetResultString(resultCode));
                break;

            case CodePrefix.MLTokenAgentResult:
                codeString = Marshal.PtrToStringAnsi(MLTokenAgent.GetResultString(resultCode));
                break;

            case CodePrefix.MLPrivilegesResult:
                codeString = Marshal.PtrToStringAnsi(MLPrivileges.GetResultString(resultCode));
                break;

            case CodePrefix.MLContactsResult:
                codeString = Marshal.PtrToStringAnsi(MLContacts.GetResultString(resultCode));
                break;

            case CodePrefix.MLLocationResult:
                codeString = Marshal.PtrToStringAnsi(MLLocation.GetResultString(resultCode));
                break;

            case CodePrefix.MLNetworkingResult:
                codeString = Marshal.PtrToStringAnsi(MLNetworkingNativeBindings.MLNetworkingGetResultString(resultCode));
                break;

            case CodePrefix.MLMovementResult:
                codeString = Marshal.PtrToStringAnsi(MLMovement.GetResultString(resultCode));
                break;

            case CodePrefix.MLConnectionsResult:
                codeString = Marshal.PtrToStringAnsi(MLConnections.GetResultString(resultCode));
                break;

            case CodePrefix.MLSecureStorageResult:
                codeString = Marshal.PtrToStringAnsi(MLSecureStorageNativeBindings.MLSecureStorageGetResultString(resultCode));
                break;

            case CodePrefix.MLAppConnect:
                codeString = Marshal.PtrToStringAnsi(MLAppConnectNativeBindings.MLAppConnectGetResultString(resultCode));
                break;

            case CodePrefix.MLWebRTC:
                codeString = Marshal.PtrToStringAnsi(MLWebRTC.NativeBindings.MLWebRTCGetResultString(resultCode));
                break;

            case CodePrefix.MLBluetoothGattResult:
                codeString = Marshal.PtrToStringAnsi(MLBluetoothLE.NativeBindings.MLBluetoothGattGetResultString(resultCode));
                break;

            default:
                // This will catch any unknown/invalid return values.
                codeString = MagicLeapNativeBindings.MLGetResultString(resultCode);
                break;
            }

            return(codeString);
        }