Class NodeOptions
- Namespace
- Codebelt.Extensions.YamlDotNet
- Assembly
- Codebelt.Extensions.YamlDotNet.dll
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
NodeOptions()
Initializes a new instance of the NodeOptions class.
public NodeOptions()
Remarks
The following table shows the initial property values for an instance of NodeOptions.
| Property | Initial Value |
|---|---|
| Anchor | YamlDotNet.Core.AnchorName.Empty |
| Tag | YamlDotNet.Core.TagName.Empty |
Properties
Anchor
Gets or sets the anchor.
public AnchorName Anchor { get; set; }
Property Value
- AnchorName
The anchor.
Tag
Gets or sets the tag.
public TagName Tag { get; set; }
Property Value
- TagName
The tag.