Search Results for

    Show / Hide Table of Contents

    Class ObjectExtensions

    Provide general purpose extension methods

    Inheritance
    System.Object
    ObjectExtensions
    Namespace: PnP.Framework.Extensions
    Assembly: PnP.Framework.dll
    Syntax
    public static class ObjectExtensions : object

    Methods

    GetPublicInstanceProperty(Object, String)

    Retrieves a public, instance property

    Declaration
    public static PropertyInfo GetPublicInstanceProperty(this object source, string propertyName)
    Parameters
    System.Object source

    The source object

    System.String propertyName

    The property name, case insensitive

    Returns
    PropertyInfo

    The property, if any

    GetPublicInstancePropertyValue(Object, String)

    Retrieves the value of a public, instance property

    Declaration
    public static Object GetPublicInstancePropertyValue(this object source, string propertyName)
    Parameters
    System.Object source

    The source object

    System.String propertyName

    The property name, case insensitive

    Returns
    Object

    The property value, if any

    NullIfEmpty(String)

    Nullify a string when it's an empty one

    Declaration
    public static string NullIfEmpty(this string value)
    Parameters
    System.String value

    Returns
    System.String

    Set<TObject, T>(TObject, Expression<Func<TObject, T>>, T, Boolean, Boolean)

    Set an object field or property and returns if the value was changed.

    Declaration
    public static bool Set<TObject, T>(this TObject target, Expression<Func<TObject, T>> propertyToSet, T valueToSet, bool allowNull = true, bool allowEmpty = true)
    Parameters
    TObject target

    target object

    Expression<Func<TObject, T>> propertyToSet

    Expression to the property or field of the object

    T valueToSet

    new value to set

    System.Boolean allowNull

    continue with set operation is null value is specified

    System.Boolean allowEmpty

    continue with set operation is null or empty value is specified

    Returns
    System.Boolean

    true if the value has changed, otherwise false

    Type Parameters
    TObject

    Type of the target object

    T

    T of the property

    SetPublicInstancePropertyValue(Object, String, Object)

    Sets the value of a public, instance property

    Declaration
    public static void SetPublicInstancePropertyValue(this object source, string propertyName, object value)
    Parameters
    System.Object source

    The source object

    System.String propertyName

    The property name, case insensitive

    System.Object value

    The value to set

    Back to top PnP Framework
    Generated by DocFX with Material UI
    spacer