private void InsertColumns() { DataTable table; foreach (var tuple in ResultSelector.GetSelectedColumns()) { switch (tuple.Key) { case "outer": table = OuterTable; break; case "inner": table = InnerTable; break; default: throw new ArgumentException("In result selector script were used different variables than outer and inner!"); } var columnName = tuple.Value; var column = table.Columns[columnName]; if (column == null) { throw new ArgumentNullException($"{table.TableName} ({tuple.Key}) does not have column {tuple.Value}!"); } Result.Columns.Add(column.ColumnName, column.DataType); } }
/// <summary> /// Monadically composes the <see cref="Result{TOk, TError}"/> with the next operation /// by either processing the successful value with the continuation, or immediately /// returning the failed value without process. /// </summary> /// <typeparam name="TOut">The type of the success value of the continuation</typeparam> /// <typeparam name="TResult"> /// The success value after combining the initial value with the value of the continuation /// </typeparam> /// <param name="selector"> /// The function which processes the successful value and returns a new /// <see cref="Result{TOut, TError}"/> /// </param> /// <param name="combine"> /// A function which combines the current successful value with the new successful value /// of the continuation and combines them into a <typeparamref name="TResult"/> /// </param> /// <remarks> /// This method is used to support multiple uses of the <c>from</c> keywords when using /// LINQ syntax. The <paramref name="combine"/> parameter is used by the LINQ syntax /// to allow multiple uses of the from clause while avoiding nested lambdas. /// </remarks> public Result <TResult, TError> SelectMany <TOut, TResult>(ResultSelector <TOk, TOut, TError> selector, Func <TOk, TOut, TResult> combine) => IsSuccess ? selector(_Ok).Select(new Combiner <TOut, TResult>(_Ok, combine).Combine) : Result <TResult, TError> .Error(_Error) ;