/// <summary> /// Execute the Func. /// </summary> /// <typeparam name="TClass">Class with methods.</typeparam> /// <typeparam name="TException">Type of exception of the exception handler.</typeparam> /// <typeparam name="TResult">Type of result.</typeparam> /// <param name="codeExecutorBuilder"><see cref="CodeExecutorBuilder{TClass, TException}"/>.</param> /// <param name="func">Executed Func.</param> /// <param name="defaultResult">Default result if exception will occured.</param> /// <returns> /// Returns result. /// </returns> public static TResult Start <TClass, TException, TResult>(this CodeExecutorBuilder <TClass, TException> codeExecutorBuilder, Func <TResult> func, TResult defaultResult = default) where TClass : class where TException : Exception { return(codeExecutorBuilder.Execute(func, defaultResult)); }
/// <summary> /// Execute the Task. /// </summary> /// <typeparam name="TClass">Class with methods.</typeparam> /// <typeparam name="TException">Type of exception of the exception handler.</typeparam> /// <typeparam name="TResult">Type of result.</typeparam> /// <param name="codeExecutorBuilder"><see cref="CodeExecutorBuilder{TClass, TException}"/>.</param> /// <param name="task">Executed Task.</param> /// <param name="defaultResult">Default result if exception will occured.</param> /// <returns> /// Returns result. /// </returns> public static async ValueTask <TResult> StartAsync <TClass, TException, TResult>(this CodeExecutorBuilder <TClass, TException> codeExecutorBuilder, ValueTask <TResult> task, TResult defaultResult = default) where TClass : class where TException : Exception { return(await codeExecutorBuilder.ExecuteAsync(task, defaultResult).ConfigureAwait(false)); }
/// <summary> /// Execute the Task. /// </summary> /// <typeparam name="TClass">Class with methods.</typeparam> /// <typeparam name="TException">Type of exception of the exception handler.</typeparam> /// <param name="codeExecutorBuilder"><see cref="CodeExecutorBuilder{TClass, TException}"/>.</param> /// <param name="task">Executed Task.</param> /// <param name="iterations">Number of executing Task iterations.</param> public static async ValueTask StartAsync <TClass, TException>(this CodeExecutorBuilder <TClass, TException> codeExecutorBuilder, ValueTask task, uint iterations = 1) where TClass : class where TException : Exception { await codeExecutorBuilder.ExecuteAsync(task, iterations).ConfigureAwait(false); }
/// <summary> /// Execute the Action. /// </summary> /// <typeparam name="TClass">Class with methods.</typeparam> /// <typeparam name="TException">Type of exception of the exception handler.</typeparam> /// <param name="codeExecutorBuilder"><see cref="CodeExecutorBuilder{TClass, TException}"/>.</param> /// <param name="action">Executed Action.</param> /// <param name="iterations">Number of executing Action iterations.</param> public static void Start <TClass, TException>(this CodeExecutorBuilder <TClass, TException> codeExecutorBuilder, Action action, uint iterations = 1) where TClass : class where TException : Exception { codeExecutorBuilder.Execute(action, iterations); }
/// <summary> /// Set exception handler for executed code. /// </summary> /// <typeparam name="TClass">Class with methods.</typeparam> /// <typeparam name="TException">Type of exception of the exception handler.</typeparam> /// <param name="codeExecutorBuilder"><see cref="CodeExecutorBuilder{TClass, TException}"/>.</param> /// <param name="exceptionHandler">Exception handler for executed code.</param> /// <returns> /// Returns <see cref="CodeExecutorBuilder{TClass, TException}"/>. /// </returns> public static CodeExecutorBuilder <TClass, TException> WithExceptionHandler <TClass, TException>(this CodeExecutorBuilder <TClass, TException> codeExecutorBuilder, Action <TException> exceptionHandler) where TClass : class where TException : Exception { return(codeExecutorBuilder.WithExceptionHandler(exceptionHandler)); }
/// <summary> /// Stop watching when executing the code. /// </summary> /// <typeparam name="TClass">Class with methods.</typeparam> /// <typeparam name="TException">Type of exception of the exception handler.</typeparam> /// <param name="codeExecutorBuilder"><see cref="CodeExecutorBuilder{TClass, TException}"/>.</param> /// <returns> /// Returns <see cref="CodeExecutorBuilder{TClass, TException}"/>. /// </returns> public static CodeExecutorBuilder <TClass, TException> WithoutWatching <TClass, TException>(this CodeExecutorBuilder <TClass, TException> codeExecutorBuilder) where TClass : class where TException : Exception { return(codeExecutorBuilder.WithoutWatching()); }
/// <summary> /// Execute the Task. /// </summary> /// <typeparam name="TClass">Class with methods.</typeparam> /// <typeparam name="TException">Type of exception of the exception handler.</typeparam> /// <param name="codeExecutorBuilder"><see cref="CodeExecutorBuilder{TClass, TException}"/>.</param> /// <param name="task">Executed Task.</param> public static async Task StartAsync <TClass, TException>(this CodeExecutorBuilder <TClass, TException> codeExecutorBuilder, Task task) where TClass : class where TException : Exception { await codeExecutorBuilder.ExecuteAsync(task).ConfigureAwait(false); }