Table of Contents

Class XmlConverterExtensions

Namespace
Cuemon.Extensions.AspNetCore.Xml.Converters
Assembly
Cuemon.Extensions.AspNetCore.Xml.dll

Extension methods for the XmlConverter class.

public static class XmlConverterExtensions
Inheritance
XmlConverterExtensions

Examples

The following example demonstrates how to register ASP.NET Core-friendly XML converters on an instance.

using System;
using System.Collections.Generic;
using Cuemon.Diagnostics;
using Cuemon.Extensions.AspNetCore.Xml.Converters;
using Cuemon.Xml.Serialization.Converters;
using Cuemon.Xml.Serialization;

namespace MyApp.Examples
{
public static class XmlConverterExtensionsExample
{
    public static void Demonstrate()
    {
        var converters = new List<XmlConverter>();
        converters.AddProblemDetailsConverter();
        converters.AddHttpExceptionDescriptorConverter(options =>
        {
            options.SensitivityDetails = FaultSensitivityDetails.All;
        });
        converters.AddStringValuesConverter();
        converters.AddHeaderDictionaryConverter();
        converters.AddQueryCollectionConverter();
        converters.AddFormCollectionConverter();
        converters.AddCookieCollectionConverter();

        var serializerOptions = new XmlSerializerOptions();
        foreach (var converter in converters)
        {
            serializerOptions.Converters.Add(converter);
        }

        Console.WriteLine(serializerOptions.Converters.Count);
        Console.WriteLine(serializerOptions.Converters[0].CanConvert(typeof(object)));
    }
}
}

Methods

AddCookieCollectionConverter(IList<XmlConverter>)

Adds an IRequestCookieCollection XML converter to the list.

public static IList<XmlConverter> AddCookieCollectionConverter(this IList<XmlConverter> converters)

Parameters

converters IList<XmlConverter>

The IList{XmlConverter} to extend.

Returns

IList<XmlConverter>

A reference to converters after the operation has completed.

AddFormCollectionConverter(IList<XmlConverter>)

Adds an IFormCollection XML converter to the list.

public static IList<XmlConverter> AddFormCollectionConverter(this IList<XmlConverter> converters)

Parameters

converters IList<XmlConverter>

The IList{XmlConverter} to extend.

Returns

IList<XmlConverter>

A reference to converters after the operation has completed.

AddHeaderDictionaryConverter(IList<XmlConverter>)

Adds an IHeaderDictionary XML converter to the list.

public static IList<XmlConverter> AddHeaderDictionaryConverter(this IList<XmlConverter> converters)

Parameters

converters IList<XmlConverter>

The list of XML converters.

Returns

IList<XmlConverter>

A reference to converters after the operation has completed.

AddHttpExceptionDescriptorConverter(IList<XmlConverter>, Action<ExceptionDescriptorOptions>)

Adds an ExceptionDescriptor XML converter to the list.

public static IList<XmlConverter> AddHttpExceptionDescriptorConverter(this IList<XmlConverter> converters, Action<ExceptionDescriptorOptions> setup = null)

Parameters

converters IList<XmlConverter>

The IList{XmlConverter} to extend.

setup Action<ExceptionDescriptorOptions>

The ExceptionDescriptorOptions which may be configured.

Returns

IList<XmlConverter>

A reference to converters after the operation has completed.

AddProblemDetailsConverter(IList<XmlConverter>)

Adds a ProblemDetails XML converter to the list.

public static IList<XmlConverter> AddProblemDetailsConverter(this IList<XmlConverter> converters)

Parameters

converters IList<XmlConverter>

The IList{XmlConverter} to extend.

Returns

IList<XmlConverter>

A reference to converters after the operation has completed.

AddQueryCollectionConverter(IList<XmlConverter>)

Adds an IQueryCollection XML converter to the list.

public static IList<XmlConverter> AddQueryCollectionConverter(this IList<XmlConverter> converters)

Parameters

converters IList<XmlConverter>

The IList{XmlConverter} to extend.

Returns

IList<XmlConverter>

A reference to converters after the operation has completed.

AddStringValuesConverter(IList<XmlConverter>)

Adds an StringValues XML converter to the list.

public static IList<XmlConverter> AddStringValuesConverter(this IList<XmlConverter> converters)

Parameters

converters IList<XmlConverter>

The IList{XmlConverter} to extend.

Returns

IList<XmlConverter>

A reference to converters after the operation has completed.