Table of Contents

Formatter Class

Definition

Provides a set of static methods that complements serialization and deserialization of an object.

public static class Formatter
Inheritance
object
Formatter

Examples

The following example shows how to resolve .NET types from qualified type-name strings using the Formatter class. It demonstrates both a direct resolution and a safe TryGetType call that avoids exceptions.

using System;
using Cuemon.Runtime.Serialization.Formatters;

namespace Cuemon.Runtime.Serialization.Formatters;

public class FormatterExample
{
    public void Demonstrate()
    {
        var type = Formatter.GetType("System.DateTime, mscorlib");
        Console.WriteLine($"Resolved type: {type}");

        if (Formatter.TryGetType("Cuemon.GuidStringOptions, Cuemon.Core", out var optionsType))
        {
            Console.WriteLine($"Found type: {optionsType}");
        }
    }
}

Methods

Name Description
GetType(string)

Gets the Type with the specified typeName, performing a case-sensitive search.

TryGetType(string, out Type)

Attempts to get the Type with the specified typeName, performing a case-sensitive search.