Skip to content

LoadedCookBook

Namespace Nfty.Core.Formats in assembly Nfty.Core.

public class LoadedCookBook : IDisposable

Owns its recipes, which own their ingredients, which own the variant images — so using var book = CookBookArchive.Read(path) frees the whole tree. Reading an archive pulls every variant PNG into memory, so a caller that opens books repeatedly (a GUI) must dispose each one.

Constructors

LoadedCookBook()

public LoadedCookBook();

Properties

Manifest

public required CookBookManifest Manifest { get; init; }

The book's manifest.

Recipes

public required IReadOnlyList<LoadedRecipe> Recipes { get; init; }

Its recipes, each owning its own ingredients.

SourceSha256

public string? SourceSha256 { get; init; }

SHA-256 of the .cbk this was read from, recorded into a generated Set so an output can be traced back to the exact archive that produced it. Null for a book that never came from a file (built in memory, or still unsaved in an editor).

Methods

Dispose()

public void Dispose();

Frees every image this object owns. Reading an archive eagerly decodes them all, so this is how a caller gives them back.

Recipe(string)

public LoadedRecipe Recipe(string id);

One of this book's recipes by id.

Parameters

  • id (string) - The recipe id.

Returns. The recipe.

Exceptions

  • KeyNotFoundException - No recipe has that id; the message names it.

TryRecipe(string, LoadedRecipe?)

public bool TryRecipe(string id, out LoadedRecipe? recipe);

One of this book's recipes by id, if it has one.

Parameters

  • id (string) - The recipe id.
  • recipe (LoadedRecipe?) - The recipe, or null.

Returns. Whether found.