XmlSerializerOptionsDecoratorExtensions Class
Definition
- Namespace
- Cuemon.Xml.Serialization
- Assemblies
- 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
| Name | Description |
|---|---|
| ApplyToDefaultSettings(IDecorator<XmlSerializerOptions>) | Applies the enclosed XmlSerializerOptions of the specified |
See Also
IDecorator<T>
Decorator<T>