Search Results for

    Show / Hide Table of Contents
    View Source

    Class ObjectExtensions

    Provides object extension methods.

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

    Methods

    View Source

    AsEnumerableOfOne<T>(T)

    Declaration
    public static IEnumerable<T> AsEnumerableOfOne<T>(this T input)
    Parameters
    Type Name Description
    T input
    Returns
    Type Description
    System.Collections.IEnumerable<T>
    Type Parameters
    Name Description
    T
    View Source

    AsGuid(Object)

    Declaration
    public static Guid AsGuid(this object value)
    Parameters
    Type Name Description
    System.Object value
    Returns
    Type Description
    Guid
    View Source

    DisposeIfDisposable(Object)

    Declaration
    public static void DisposeIfDisposable(this object input)
    Parameters
    Type Name Description
    System.Object input
    View Source

    SafeCast<T>(Object)

    Provides a shortcut way of safely casting an input when you cannot guarantee the T is an instance type (i.e., when the C# AS keyword is not applicable).

    Declaration
    public static T SafeCast<T>(this object input)
    Parameters
    Type Name Description
    System.Object input

    The input.

    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    View Source

    ToDictionary<TVal>(Object, String[])

    Turns object into dictionary

    Declaration
    public static IDictionary<string, TVal> ToDictionary<TVal>(this object o, params string[] ignoreProperties)
    Parameters
    Type Name Description
    System.Object o
    System.String[] ignoreProperties

    Properties to ignore

    Returns
    Type Description
    System.Collections.IDictionary<System.String, TVal>
    Type Parameters
    Name Description
    TVal
    View Source

    ToDictionary<T, TProperty, TVal>(T, Expression<Func<T, TProperty>>[])

    Converts an object into a dictionary

    Declaration
    public static IDictionary<string, TVal>? ToDictionary<T, TProperty, TVal>(this T o, params Expression<Func<T, TProperty>>[] ignoreProperties)
    Parameters
    Type Name Description
    T o
    System.Linq.Expressions.Expression<Func<T, TProperty>>[] ignoreProperties
    Returns
    Type Description
    System.Nullable<System.Collections.IDictionary<System.String, TVal>>
    Type Parameters
    Name Description
    T
    TProperty
    TVal
    View Source

    ToXmlString(Object, Type)

    Returns an XmlSerialized safe string representation for the value

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

    The Type can only be a primitive type or Guid and byte[] otherwise an exception is thrown

    Returns
    Type Description
    System.String
    View Source

    ToXmlString<T>(Object)

    Returns an XmlSerialized safe string representation for the value and type

    Declaration
    public static string ToXmlString<T>(this object value)
    Parameters
    Type Name Description
    System.Object value
    Returns
    Type Description
    System.String
    Type Parameters
    Name Description
    T
    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
    System.Object input

    The input.

    Type target

    The type to convert to

    Returns
    Type Description
    Attempt<System.Object>

    The Attempt<TResult>

    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
    System.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

    • Improve this Doc
    • View Source
    In This Article
    • Methods
      • AsEnumerableOfOne<T>(T)
      • AsGuid(Object)
      • DisposeIfDisposable(Object)
      • SafeCast<T>(Object)
      • ToDictionary<TVal>(Object, String[])
      • ToDictionary<T, TProperty, TVal>(T, Expression<Func<T, TProperty>>[])
      • ToXmlString(Object, Type)
      • ToXmlString<T>(Object)
      • TryConvertTo(Object, Type)
      • TryConvertTo<T>(Object)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX