Table of Contents

XmlSerializerOptionsExtensions Class

Definition

Extension methods for the XmlSerializerOptions class.

public static class XmlSerializerOptionsExtensions
Inheritance
XmlSerializerOptionsExtensions

Examples

The following example demonstrates how to apply custom XmlSerializerOptions to the default settings using the XmlSerializerOptionsExtensions class.

using System;
using System.Text;
using System.Xml;
using Cuemon.Extensions.Xml.Serialization;
using Cuemon.Xml.Serialization;

namespace MyApp.Examples;

public class XmlSerializerOptionsExtensionsExample
{
    public void Demonstrate()
    {
        // Configure XmlSerializerOptions
        var options = new XmlSerializerOptions
        {
            Reader = new XmlReaderSettings { IgnoreWhitespace = true },
            Writer = new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 }
        };

        // Apply to default XmlConvert settings
        options.ApplyToDefaultSettings();

        // After this call, XmlConvert.DefaultSettings will reflect the options

}
}

Methods

Name Description
ApplyToDefaultSettings(XmlSerializerOptions)

Applies the specified options to the function delegate DefaultSettings.