Class PropertyAccess
Utility class that provides property access based on strings.
Inherited Members
Namespace: Radzen
Assembly: Radzen.Blazor.dll
Syntax
public static class PropertyAccess
Methods
DateOnlyFromDateTime(DateTime)
Converts a DateTime to DateOnly.
Declaration
public static object DateOnlyFromDateTime(DateTime source)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | source | The source DateTime. |
Returns
| Type | Description |
|---|---|
| object | DateOnly object or null. |
GetDynamicPropertyExpression(string, Type)
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 |
|---|---|
| string | Dynamic property expression. |
GetElementType(Type)
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 |
|---|---|
| Type | The type of the collection element. |
GetItemOrValueFromProperty(object, string)
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 |
|---|---|
| object | System.Object. |
GetProperty(string)
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 |
|---|---|
| string | The property string. |
GetProperty(Type, string)
Gets the property by its name. If the type is an interface, it will search through all interfaces implemented by the type.
Declaration
public static PropertyInfo GetProperty(Type type, string property)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type. |
| string | property | The property. |
Returns
| Type | Description |
|---|---|
| PropertyInfo | PropertyInfo. |
GetPropertyType(Type, string)
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 |
|---|---|
| Type | Type. |
GetValue(object, string)
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 |
|---|---|
| object | The value of the specified expression or |
Getter<T>(object, string)
Creates a function that returns the specified property.
Declaration
public static Func<object, T> Getter<T>(object data, string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| object | data | The value. |
| string | propertyName | The name of the property to return. |
Returns
| Type | Description |
|---|---|
| Func<object, T> | A function that returns the specified property. |
Type Parameters
| Name | Description |
|---|---|
| T | The value type |
Getter<TItem, TValue>(string, Type)
Creates a function that will return the specified property.
Declaration
public static Func<TItem, TValue> Getter<TItem, TValue>(string propertyName, Type type = null)
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. |
Type Parameters
| Name | Description |
|---|---|
| TItem | The owner type. |
| TValue | The value type. |
IsAnonymous(Type)
Determines whether the specified type is anonymous.
Declaration
public static bool IsAnonymous(this Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type. |
Returns
| Type | Description |
|---|---|
| bool |
|
IsDate(Type)
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 |
|---|---|
| bool |
|
IsDateOnly(Type)
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 |
|---|---|
| bool |
|
IsEnum(Type)
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 |
|---|---|
| bool |
|
IsNullableEnum(Type)
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 |
|---|---|
| bool |
|
IsNumeric(Type)
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 |
|---|---|
| bool |
|
ReplaceFirst(string, string, string)
Method to only replace first occurence of a substring in a string
Declaration
public static string ReplaceFirst(this 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 |
|---|---|
| string | The modified string. |
TryGetItemOrValueFromProperty<T>(object, string, out T)
Tries to get a property by its name.
Declaration
public static bool TryGetItemOrValueFromProperty<T>(object item, string property, out T result)
Parameters
| Type | Name | Description |
|---|---|---|
| object | item | The item. |
| string | property | The property. |
| T | result | The property value. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The target type |