Table of Contents

Class Wrapper

Namespace
Cuemon.Extensions
Assembly
Cuemon.Extensions.Core.dll

Provides helper method for a Wrapper<T> object.

public static class Wrapper
Inheritance
Wrapper

Examples

The following example demonstrates how to wrap values using Wrapper<T> to access the inner instance, its type, and a parsed string representation. It shows wrapping both an integer and a string value.

using System;
using Cuemon;
using Cuemon.Extensions;

namespace Cuemon.Extensions;

public class WrapperExample
{
    public void Demonstrate()
    {
        var wrapped = new Wrapper<int>(42);
        Console.WriteLine(wrapped.Instance);
        Console.WriteLine(wrapped.InstanceType);

        string parsed = Wrapper.ParseInstance(wrapped);
        Console.WriteLine(parsed);

        int asInt = wrapped.InstanceAs<int>();
        Console.WriteLine(asInt);

        var wrappedString = new Wrapper<string>("Hello, World!");
        Console.WriteLine(Wrapper.ParseInstance(wrappedString));
    }
}

Methods

ParseInstance<T>(IWrapper<T>)

Parses the encapsulated instance of the specified wrapper for a human-readable string value.

public static string ParseInstance<T>(IWrapper<T> wrapper)

Parameters

wrapper IWrapper<T>

The wrapper object to parse the instance.

Returns

string

A human-readable string representation of the wrapped instance in the Wrapper<T> object.

Type Parameters

T

The type of the encapsulated instance of wrapper.

Exceptions

ArgumentNullException

wrapper is null.