PropertyAccess Class

Utility class that provides property access based on strings.

Inheritance

Object

PropertyAccess

Namespace: Radzen

Assembly: Radzen.Blazor.dll

Syntax

public static class PropertyAccess

Methods

DateOnlyFromDateTimelink

Converts a DateTime to DateOnly.

Declaration
public static object DateOnlyFromDateTime(DateTime source)
Parameters
Type Name Description
DateTime source The source DateTime.
Returns
Type Description
objectDateOnly object or null.

GetDynamicPropertyExpressionlink

Gets the dynamic property expression when binding to IDictionary.

Declaration
public static string GetDynamicPropertyExpression(string name, Type type)
Parameters
Type Name Description
string name The property name.
Type type The property type.
Returns
Type Description
stringDynamic property expression.

GetElementTypelink

Gets the type of the element of a collection time.

Declaration
public static Type GetElementType(Type type)
Parameters
Type Name Description
Type type The type.
Returns
Type Description
TypeThe type of the collection element.

GetItemOrValueFromPropertylink

Gets the item or value from property.

Declaration
public static object GetItemOrValueFromProperty(object item, string property)
Parameters
Type Name Description
object item The item.
string property The property.
Returns
Type Description
objectSystem.Object.

GetPropertylink

Converts the property to a value that can be used by Dynamic LINQ.

Declaration
public static string GetProperty(string property)
Parameters
Type Name Description
string property The property.
Returns
Type Description
stringThe property string.

GetPropertylink

Converts the property to a value that can be used by Dynamic LINQ.

Declaration
public static Reflection.PropertyInfo GetProperty(Type type, string property)
Parameters
Type Name Description
Type type
string property The property.
Returns
Type Description
Reflection.PropertyInfoThe property string.

GetPropertyTypelink

Gets the type of the property.

Declaration
public static Type GetPropertyType(Type type, string property)
Parameters
Type Name Description
Type type The type.
string property The property.
Returns
Type Description
TypeType.

GetValuelink

Gets the value of the specified expression via reflection.

Declaration
public static object GetValue(object value, string path)
Parameters
Type Name Description
object value The value.
string path The path.
Returns
Type Description
objectThe value of the specified expression or value if not found.

Getterlink

Creates a function that will return the specified property.

Declaration
public static Func<TItem, TValue> Getter(string propertyName, Type type)
Parameters
Type Name Description
string propertyName Name of the property to return.
Type type Type of the object.
Returns
Type Description
Func<TItem, TValue>A function which return the specified property by its name.

Getterlink

Creates a function that will return the specified property.

Declaration
public static Func<object, T> Getter(object data, string propertyName)
Parameters
Type Name Description
object data
string propertyName Name of the property to return.
Returns
Type Description
Func<object, T>A function which return the specified property by its name.

IsAnonymouslink

Determines whether the specified type is anonymous.

Declaration
public static bool IsAnonymous(Type type)
Parameters
Type Name Description
Type type The type.
Returns
Type Description
booltrue if the specified type is anonymous; otherwise, false.

IsDatelink

Determines whether the specified type is a DateTime.

Declaration
public static bool IsDate(Type source)
Parameters
Type Name Description
Type source The source.
Returns
Type Description
booltrue if the specified type is a DateTime instance or nullable DateTime; otherwise, false.

IsDateOnlylink

Determines whether the specified type is a DateOnly.

Declaration
public static bool IsDateOnly(Type source)
Parameters
Type Name Description
Type source The source.
Returns
Type Description
booltrue if the specified type is a DateOnly instance or nullable DateOnly; otherwise, false.

IsEnumlink

Determines whether the specified type is an enum.

Declaration
public static bool IsEnum(Type source)
Parameters
Type Name Description
Type source The type.
Returns
Type Description
booltrue if the specified source is an enum; otherwise, false.

IsNullableEnumlink

Determines whether the specified type is a Nullable enum.

Declaration
public static bool IsNullableEnum(Type source)
Parameters
Type Name Description
Type source The type.
Returns
Type Description
booltrue if the specified source is an enum; otherwise, false.

IsNumericlink

Determines whether the specified type is numeric.

Declaration
public static bool IsNumeric(Type source)
Parameters
Type Name Description
Type source The type.
Returns
Type Description
booltrue if the specified source is numeric; otherwise, false.

ReplaceFirstlink

Method to only replace first occurence of a substring in a string

Declaration
public static string ReplaceFirst(string text, string search, string replace)
Parameters
Type Name Description
string text The text to search in.
string search The string to search for.
string replace The replacement string.
Returns
Type Description
stringThe modified string.

TryGetItemOrValueFromPropertylink

Tries to get a property by its name.

Declaration
public static bool TryGetItemOrValueFromProperty(object item, string property, T& result)
Parameters
Type Name Description
object item The item.
string property The property.
T& result The property value.
Returns
Type Description
booltrue if successful, false otherwise.
In This Article
An error has occurred. This app may no longer respond until reloaded. Reload 🗙