Table of Contents

NodeOptions Class

Definition

Namespace
Codebelt.Extensions.YamlDotNet
Assemblies
Codebelt.Extensions.YamlDotNet.dll
Source
src/Codebelt.Extensions.YamlDotNet/NodeOptions.cs

Configuration options for EmitterExtensions.

public class NodeOptions : IParameterObject
Inheritance
NodeOptions
Implements
Derived

Examples

The following example demonstrates how to use NodeOptions to configure YAML node properties like anchors and tags when writing low-level YAML output.

using System;
using System.IO;
using Codebelt.Extensions.YamlDotNet;
using YamlDotNet.Core;
using YamlDotNet.Serialization;

namespace ExampleNamespace;

class Program
{
    static void Main()
    {
        var stringWriter = new StringWriter();
        var emitter = new Emitter(stringWriter);
        
        // Create and configure node options with anchor and tag
        var nodeOptions = new NodeOptions
        {
            Anchor = new AnchorName("myanchor"),
            Tag = new TagName("!custom-tag")
        };
        
        // These options can be passed to emitter extensions when writing YAML
        // For example, when creating a custom converter
        
        // Write a simple configuration using basic NodeOptions
        emitter.WriteStartObject();
        emitter.WriteString("name", "Configuration");
        emitter.WriteString("value", "example");
        emitter.WriteEndObject();
        
        var yaml = stringWriter.ToString();
        Console.WriteLine(yaml);
    }
}

Constructors

Name Description
NodeOptions()

Initializes a new instance of the NodeOptions class.

Properties

Name Description
Anchor

Gets or sets the anchor.

Tag

Gets or sets the tag.