private static Func <int, byte, byte> MakeCalculationFunc(MathMode mode, bool wrapAround) { Func <int, byte> wrapAroundFunc = MakeWrapAroundFunc(wrapAround); Func <int, byte, byte> calculationFunc; switch (mode) { case MathMode.Add: calculationFunc = (providedValue, inputByte) => wrapAroundFunc(inputByte + providedValue); break; case MathMode.Subtract: calculationFunc = (providedValue, inputByte) => wrapAroundFunc(inputByte - providedValue); break; case MathMode.Divide: calculationFunc = (providedValue, inputByte) => { if (providedValue == 0) { return(inputByte); } else { return(wrapAroundFunc(inputByte / providedValue)); } }; break; case MathMode.Multiply: calculationFunc = (providedValue, inputByte) => wrapAroundFunc(inputByte * providedValue); break; default: throw new ArgumentException("Unknown math mode", nameof(mode)); } return(calculationFunc); }
/// <summary> /// Enables fast generation of fast math methods using the math mode provided. /// </summary> /// <param name="mathMode">The math mode to use.</param> /// <returns>The current builder instance.</returns> public Builder Math(MathMode mathMode) { MathMode = mathMode; return(this); }
public string ConvertContent(string content) { content = new MathMode(content, "").WriteComponent(); content = Regex.Replace(content, @"(?<!\n)\r", Environment.NewLine); return($"{content}"); }
internal CodeTableInfo(string word, string tex, MathMode mm) { Word = word; TeX = tex; MathMode = mm; }