// allArgs should start with a null placeholder for the RNG object /// <summary> /// Invokes the with RNG. /// </summary> /// <param name="seed">The seed.</param> /// <param name="method">The method.</param> /// <param name="allArgs">All arguments.</param> private static void InvokeWithRng(int?seed, MethodInfo method, params object[] allArgs) { if (!seed.HasValue) { seed = seedGen.Next(); } IntPtr rng; NativeWrapper.CheckResult(CpuOpsNative.TS_NewRNG(out rng)); NativeWrapper.CheckResult(CpuOpsNative.TS_SetRNGSeed(rng, seed.Value)); allArgs[0] = rng; NativeWrapper.InvokeTypeMatch(method, allArgs); NativeWrapper.CheckResult(CpuOpsNative.TS_DeleteRNG(rng)); }