// Token: 0x0600035C RID: 860 RVA: 0x00010C94 File Offset: 0x0000EE94 public void PoisonCall(EmergencyKit kit, TryDelegate dangerousCall) { PoisonControl.< > c__DisplayClass1 CS$ < > 8__locals1 = new PoisonControl.< > c__DisplayClass1(); CS$ < > 8__locals1.kit = kit; CS$ < > 8__locals1.< > 4__this = this; ILUtil.DoTryFilterCatch(dangerousCall, new FilterDelegate(CS$ < > 8__locals1, (UIntPtr)ldftn(< PoisonCall > b__0)), null); }
internal Lexer(JinjaEnvironment environment) { Environment = environment; _Delegates = new TryDelegate[] { TryNewLine, TryWhiteSpace, TryKeyword, TrySingleChar, }; _KeywordLookups.Add(environment.Settings.BlockStartString.ToCharArray(), TokenType.StatementStart); _KeywordLookups.Add(environment.Settings.BlockEndString.ToCharArray(), TokenType.StatementEnd); _KeywordLookups.Add(environment.Settings.VariableStartString.ToCharArray(), TokenType.ExpressionStart); _KeywordLookups.Add(environment.Settings.VariableEndString.ToCharArray(), TokenType.ExpressionEnd); _KeywordLookups.Add(environment.Settings.CommentStartString.ToCharArray(), TokenType.CommentStart); _KeywordLookups.Add(environment.Settings.CommentEndString.ToCharArray(), TokenType.CommentEnd); if (environment.Settings.LineCommentPrefix != null) { _KeywordLookups.Add(environment.Settings.LineCommentPrefix.ToCharArray(), TokenType.LineComment); } if (environment.Settings.LineStatementPrefix != null) { _KeywordLookups.Add(environment.Settings.LineStatementPrefix.ToCharArray(), TokenType.LineStatement); } }
private static string TryGetOrDefault(TryDelegate getter, string defaultValue) { if (getter(out string result)) { return(result); } return(defaultValue); }
static void TryTest(TryDelegate d) { try { d(); } catch (Exception e) { Console.WriteLine("Error: {0}", e); } }
public bool TryExecute(TryDelegate task) { TransientExceptionHandler.< > c__DisplayClass1 CS$ < > 8__locals1 = new TransientExceptionHandler.< > c__DisplayClass1(); CS$ < > 8__locals1.< > 4__this = this; ArgumentValidator.ThrowIfNull("task", task); CS$ < > 8__locals1.exception = null; CS$ < > 8__locals1.needToRetry = false; ILUtil.DoTryFilterCatch(task, this.transientExceptionFilter, new CatchDelegate(CS$ < > 8__locals1, (UIntPtr)ldftn(< TryExecute > b__0))); if (!CS$ < > 8__locals1.needToRetry) { this.TransientExceptionCount = 0; this.tracer.TraceDebug((long)this.GetHashCode(), "TransientExceptionHandler.TryExecute: Task completed successfully and the retry count has beeen restarted."); }
public static T?ParseNullable <T>(string s, TryDelegate <T> tryDelegate) where T : struct { if (s == null) { return(null); } T temp; return(tryDelegate(s, out temp) ? (T?)temp : null); }
public static bool TryParseNullable <T>(string s, out T?result, TryDelegate <T> tryDelegate) where T : struct { if (s == null) { result = null; return(true); } T temp; bool success = tryDelegate(s, out temp); result = temp; return(success); }
public void ExecuteWithRetry(TryDelegate task) { ArgumentValidator.ThrowIfNull("task", task); while (!this.TryExecute(task)) { if (this.budget != null) { this.budget.EndLocal(); } if (this.delayBetweenAttempts > TimeSpan.Zero) { this.tracer.TraceDebug <TimeSpan>((long)this.GetHashCode(), "TransientExceptionHandler.ExecuteWithRetry: Sleeping thread for {0}.", this.delayBetweenAttempts); Thread.Sleep(this.delayBetweenAttempts); } if (this.budget != null) { this.budget.StartLocal(this.callerInfo, default(TimeSpan)); } } }
/// <summary> /// Returns the assigned value if the supplied try function returns true for the specified input. /// </summary> /// <typeparam name="TIn">The type of the input.</typeparam> /// <typeparam name="TOut">The type of the output.</typeparam> /// <param name="tryFunction">The try function.</param> /// <param name="input">The input.</param> /// <param name="unassignedOnNull"> /// if set to <c>true</c> returns <see cref="Unassigned" /> if <paramref name="tryFunction" /> outputs a /// <see langword="null" />, /// even when it returns <see langword="true" />. /// </param> /// <returns>Optional{`0}.</returns> public static Optional <T> UnassignedOnFailure <TIn, TOut>( [NotNull] TryDelegate <TIn, TOut> tryFunction, TIn input, bool unassignedOnNull = false) where TOut : T { if (tryFunction == null) { throw new ArgumentNullException("tryFunction"); } TOut result; if (tryFunction(input, out result)) { return(unassignedOnNull && ReferenceEquals(result, null) ? Unassigned : new Optional <T>(result, true)); } return(Unassigned); }
public static Maybe <TResult> FromTryOut <TResult>(TryDelegate <string, TResult> call, string value) { TResult result; return(call(value, out result) ? Just(result) : Nothing); }
private static string TryGetOrDefault(TryDelegate getter, string defaultValue) { string result; if (getter(out result)) { return result; } return defaultValue; }
public static T?Parse <T>(string s, TryDelegate <T> tryDelegate) where T : struct { return(tryDelegate(s, out T value) ? value : default(T?)); }
public static Maybe <TResult> FromTryOut <TResult>([InstantHandle] TryDelegate <string, TResult> call, string value) => FromTryOut <string, TResult>(call, value);
public static Maybe <TResult> FromTryOut <TArg, TResult>([InstantHandle] TryDelegate <TArg, TResult> call, TArg value) { TResult result; return(call(value, out result) ? Just(result) : Maybe <TResult> .Nothing); }