Search Results for

    Show / Hide Table of Contents
    View Source

    Class ObjectExtensions

    Provides object extension methods.

    Inheritance
    object
    Namespace: Umbraco.Extensions
    Assembly: Umbraco.Core.dll
    Syntax
    public static class ObjectExtensions

    Methods

    View Source

    AsEnumerableOfOne<T>(T)

    Returns an enumerable containing only the input object.

    Declaration
    [Obsolete("Please replace uses of this extension method with Enumerable.Repeat(input, 1). This extension method is no longer used in Umbraco and is scheduled for removal in Umbraco 19.")]
    public static IEnumerable<T> AsEnumerableOfOne<T>(this T input)
    Parameters
    Type Name Description
    T input

    The input object.

    Returns
    Type Description
    IEnumerable<T>

    An enumerable containing only the input object.

    Type Parameters
    Name Description
    T

    The type of the enumerable.

    View Source

    ToXmlString(object, Type)

    Returns an XML serialized safe string representation for the value and type.

    Declaration
    public static string ToXmlString(this object value, Type type)
    Parameters
    Type Name Description
    object value

    The value.

    Type type

    The type of the value. This can only be a primitive type or System.Guid and byte[], otherwise an exception is thrown.

    Returns
    Type Description
    string

    The XML serialized safe string representation.

    View Source

    ToXmlString<T>(object)

    Returns an XML serialized safe string representation for the value and type.

    Declaration
    public static string ToXmlString<T>(this object value)
    Parameters
    Type Name Description
    object value

    The value.

    Returns
    Type Description
    string

    The XML serialized safe string representation.

    Type Parameters
    Name Description
    T

    The type of the value.

    View Source

    TryConvertTo(object?, Type)

    Attempts to convert the input object to the output type.

    Declaration
    public static Attempt<object?> TryConvertTo(this object? input, Type target)
    Parameters
    Type Name Description
    object input

    The input.

    Type target

    The type to convert to.

    Returns
    Type Description
    Attempt<object>

    The .

    Remarks

    This code is an optimized version of the original Umbraco method.

    View Source

    TryConvertTo<T>(object?)

    Attempts to convert the input object to the output type.

    Declaration
    public static Attempt<T> TryConvertTo<T>(this object? input)
    Parameters
    Type Name Description
    object input

    The input.

    Returns
    Type Description
    Attempt<T>

    The Attempt<TResult>.

    Type Parameters
    Name Description
    T

    The type to convert to.

    Remarks

    This code is an optimized version of the original Umbraco method.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX