Class PropertyAccess
Utility class that provides property access based on strings.
Inheritance
Namespace: Radzen
Assembly: Radzen.Blazor.dll
Syntax
public static class PropertyAccess : object
Methods
DateOnlyFromDateTime(DateTime)
Determines whether the specified type is a DateOnly.
Declaration
public static object DateOnlyFromDateTime(DateTime source)
Parameters
Type | Name | Description |
---|---|---|
DateTime | source | The source. |
Returns
Type | Description |
---|---|
System.Object |
|
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 |
---|---|---|
System.String | name | The property name. |
Type | type | The property type. |
Returns
Type | Description |
---|---|
System.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 |
---|---|---|
System.Object | item | The item. |
System.String | property | The property. |
Returns
Type | Description |
---|---|
System.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 |
---|---|---|
System.String | property | The property. |
Returns
Type | Description |
---|---|
System.String |
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. |
System.String | property | The property. |
Returns
Type | Description |
---|---|
Type | Type. |
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 |
---|---|---|
System.Object | data | The value. |
System.String | propertyName | The name of the property to return. |
Returns
Type | Description |
---|---|
Func<System.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 |
---|---|---|
System.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. |
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 |
---|---|---|
System.Object | value | The value. |
System.String | path | The path. |
Returns
Type | Description |
---|---|
System.Object | The value of the specified expression or |
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 |
---|---|
System.Boolean |
|
IsDate(Type)
Determines whether the specified type is a
Declaration
public static bool IsDate(Type source)
Parameters
Type | Name | Description |
---|---|---|
Type | source | The source. |
Returns
Type | Description |
---|---|
System.Boolean |
|
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 |
---|---|
System.Boolean |
|
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 |
---|---|
System.Boolean |
|
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 |
---|---|
System.Boolean |
|
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 |
---|---|
System.Boolean |
|
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 |
---|---|---|
System.String | text | |
System.String | search | |
System.String | replace |
Returns
Type | Description |
---|---|
System.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 |
---|---|---|
System.Object | item | The item. |
System.String | property | The property. |
T | result | The property value. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Type Parameters
Name | Description |
---|---|
T | The target type |