Exemplo n.º 1
0
 /// <summary>
 /// Returns a pattern with the specified name from the engine's cache. If the pattern doesn't exist, it is loaded from
 /// file.
 /// </summary>
 /// <param name="name">The name or path of the pattern to retrieve.</param>
 /// <returns></returns>
 internal RantProgram GetProgramInternal(string name)
 {
     if (_patternCache.TryGetValue(name, out RantProgram pattern))
     {
         return(pattern);
     }
     return(_patternCache[name] = RantProgram.CompileFile(name));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Loads the file located at the specified path and executes it using a custom seed, returning the resulting output.
 /// </summary>
 /// <param name="path">The path to the file to execute.</param>
 /// <param name="rng">The random number generator to use when generating output.</param>
 /// <param name="charLimit">
 /// The maximum number of characters that can be printed. An exception will be thrown if the limit
 /// is exceeded. Set to zero or below for unlimited characters.
 /// </param>
 /// <param name="timeout">The maximum number of seconds that the pattern will execute for.</param>
 /// <param name="args">The arguments to pass to the pattern.</param>
 /// <returns></returns>
 public RantOutput DoFile(string path, RNG rng, int charLimit = 0, double timeout = -1, RantProgramArgs args = null) =>
 RunVM(new Sandbox(this, RantProgram.CompileFile(path), rng, charLimit, GetPreservedCarrierState(), args), timeout);