This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.CompilerServices; | |
// our code | |
MyType obj = new(); | |
MyExtension ext = (MyExtension)obj; | |
ext.MyField = 42; | |
// other code | |
ext = (MyExtension)obj; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Retry | |
{ | |
public static async Task<T> DoAsync<T>(Func<Task<T>> action, | |
Func<T, bool> validateResult = null, | |
int maxRetries = 10, int maxDelayMilliseconds = 2000, int delayMilliseconds = 200) | |
{ | |
var backoff = new ExponentialBackoff(delayMilliseconds, maxDelayMilliseconds); | |
var exceptions = new List<Exception>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Random Number Generator based on Mersenne-Twister algorithm | |
/// | |
/// Usage : | |
/// RandomNumberGenerator.Instance.Generate()); | |
/// RandomNumberGenerator.Instance.Generate(1.1,2.2); | |
/// RandomNumberGenerator.Instance.Generate(1,100) | |
/// | |
/// inspired from : http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/C-LANG/980409/mt19937-2.c | |
/// </summary> |