public TSLGeneratorCombinator(double probability, GenerateDelegate generateFunc, TSLGeneratorCombinator <R> next = null) { Probability = probability; CumulativeProbability = probability + (next?.CumulativeProbability ?? 0.0); GenerateFunc = generateFunc; NextCombinator = next; }
public static Func <TSLGeneratorContext, ITSLType> GenerateNonNullType(TSLGeneratorCombinator <ITSLType> generator) { return(context => { ITSLType ret = null; for (int i = 0; i < GeneralSettings.NonNullRetries; ++i) { ret = generator.DefaultGenerate(context); if (ret != null) { return ret; } } throw new Exception("Too many retries before getting a non null type!"); }); }
public TSLGeneratorCombinator <R> WithNext(TSLGeneratorCombinator <R> next) => new TSLGeneratorCombinator <R>(Probability, GenerateFunc, next);