NBoomackClient
Show / Hide Table of Contents

Preset Management

Managing presets encompasses the following interactions:

  • Listing all preset IDs
  • Getting the display options of a preset
  • Creating or updating a preset
  • Deleting a preset

The following examples assume you already have a configured BoomackClient instance in the variable client. See Get Started if you do not know how to configure a BoomackClient instance.

List Preset IDs

The method GetPresetIds() returns a IdListResponse, which is an enumerable of strings.

var response = await client.GetPresetIds();
foreach (var id in response)
{
    Console.WriteLine("- " + id);
}

Get Preset

The method GetPreset(string) returns a DisplayOptionsResponse.

var response = await client.GetPreset("my-preset");
var options = response.DisplayOptions;
Console.WriteLine("Text Transformation: {0}", options.Transformation);
Console.WriteLine("Syntax: {0}", options.Syntax);

Create or Update Preset

On the HTTP API level of the Boomack Server, creating and updating are the same operation. Both are implemented by an HTTP PUT request.

To make the code using this client library more readable, however, two methods are available that do the same thing in the background:

  • AddPreset(string, DisplayOptions)
  • UpdatePreset(string, DisplayOptions)
var options = new DisplayOptions()
{
    Transformation = "highlight",
    Syntax = "csharp",
};
await client.AddPreset("my-preset", options);

Delete Preset

For the deletion of a preset you just need the preset ID.

await client.DeletePreset("my-preset");

Next: Media Type Management

In This Article
Back to top
Boomack Homepage