Class XmlSerializerOptionsDecoratorExtensions
- Namespace
- Cuemon.Xml.Serialization
- Assembly
- Cuemon.Xml.dll
Extension methods for the XmlSerializerOptions class hidden behind the IDecorator<T> interface.
public static class XmlSerializerOptionsDecoratorExtensions
- Inheritance
-
XmlSerializerOptionsDecoratorExtensions
Examples
The following example demonstrates how to use the ApplyToDefaultSettings extension method to apply XmlSerializerOptions to the global XmlConvert.DefaultSettings.
using System;
using System.Xml;
using Cuemon;
using Cuemon.Xml.Serialization;
namespace MyApp.Examples;
public class XmlSerializerOptionsDecoratorExtensionsExample
{
public static void Main()
{
var options = new XmlSerializerOptions
{
Writer = new XmlWriterSettings { Indent = true, IndentChars = " " },
RootName = new XmlQualifiedEntity("CustomRoot")
};
// Apply the options as the default XmlWriterSettings globally.
Decorator.Enclose(options).ApplyToDefaultSettings();
// When running XmlConvert.EncodeName or similar, the default settings apply.
Console.WriteLine("Default settings applied successfully.");
}
}
Methods
ApplyToDefaultSettings(IDecorator<XmlSerializerOptions>)
Applies the enclosed XmlSerializerOptions of the specified decorator to the function delegate DefaultSettings.
public static void ApplyToDefaultSettings(this IDecorator<XmlSerializerOptions> decorator)
Parameters
decoratorIDecorator<XmlSerializerOptions>The IDecorator{XmlSerializerOptions} to extend.
Exceptions
- ArgumentNullException
decoratorcannot be null.
See Also
IDecorator<T>
Decorator<T>