View Source
  Class ObjectExtensions
  
  Provides object extension methods.
    Inheritance
      System.Object
      
   
  
  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
  
  
    View Source
  
  AsGuid(Object)
  
  
  Declaration
  
    public static Guid AsGuid(this object value)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | System.Object | value |  | 
    
  
  Returns
  
  
    View Source
  
  DisposeIfDisposable(Object)
  Disposes the object if it implements .
Declaration
  
    public static void DisposeIfDisposable(this object input)
   
  Parameters
  
    
      
        | Type | Name | Description | 
    
    
      
        | System.Object | input | The object. | 
    
  
  
    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 Parameters
  
  
    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
  
  
    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
  
  
    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
  
  
  
  
    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 Parameters
  
    
      
        | Name | Description | 
    
    
      
        | T | The type to convert to |