Beispiel #1
0
 public static void ThrowIfSdlActionFails(Action tryAction, [CallerMemberName] string methodName = null)
 {
     try {
         tryAction();
     }
     catch (Exception exc) {
         var prefix = methodName + ": ";
         throw SdlNativeException.CreateFromLastSdlError(prefix, exc);
     }
 }
Beispiel #2
0
 public static void ThrowIfSdlActionFails <TArg0, TArg1, TArg2, TArg3>(Action <TArg0, TArg1, TArg2, TArg3> tryAction, TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3, [CallerMemberName] string methodName = null)
 {
     try {
         tryAction(arg0, arg1, arg2, arg3);
     }
     catch (Exception exc) {
         var prefix = methodName + ": ";
         throw SdlNativeException.CreateFromLastSdlError(prefix, exc);
     }
 }
Beispiel #3
0
        public static void ThrowIfSdlCallFails <TArg0, TArg1>(Func <TArg0, TArg1, int> tryFunction, TArg0 arg0, TArg1 arg1, [CallerMemberName] string methodName = null)
        {
            var resultCode = tryFunction(arg0, arg1);

            if (0 == resultCode)
            {
                return;
            }

            var prefix = methodName + ": ";

            throw SdlNativeException.CreateFromLastSdlError(prefix);
        }
Beispiel #4
0
        public static TResult ThrowIfSdlFuncFails <TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(Func <TArg0, TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult> tryFunction, TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5, TArg6 arg6, [CallerMemberName] string methodName = null)
        {
            var result = tryFunction(arg0, arg1, arg2, arg3, arg4, arg5, arg6);

            if (null != result)
            {
                return(result);
            }

            var prefix = methodName + ": ";

            throw SdlNativeException.CreateFromLastSdlError(prefix);
        }
Beispiel #5
0
        public static TResult ThrowIfSdlFuncFails <TResult>(Func <TResult> tryFunction, [CallerMemberName] string methodName = null)
        {
            var result = tryFunction();

            if (null != result)
            {
                return(result);
            }

            var prefix = methodName + ": ";

            throw SdlNativeException.CreateFromLastSdlError(prefix);
        }