예제 #1
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);
        }