PeanutButter
|
Provides a single storage / representation for a Property or a Field. More...
Public Member Functions | |||||||
PropertyOrField (PropertyInfo prop) | |||||||
Constructs the PropertyOrField around a property. | |||||||
PropertyOrField (PropertyInfo prop, Type hostingType) | |||||||
Constructs the PropertyOrField around a property, relative to an hosting type (ie, without assuming that the DeclaringType is the hosting type for the property) | |||||||
PropertyOrField (FieldInfo field) | |||||||
Constructs the PropertyOrField around a field. | |||||||
PropertyOrField (FieldInfo field, Type hostingType) | |||||||
Constructs the PropertyOrField around a field. | |||||||
object | GetValue (object host) | ||||||
Gets the value of the property or field for the provided host.
| |||||||
object | GetValueAt (object host, object index) | ||||||
Get the value at the provided index into a collection.
| |||||||
bool | TryGetValue (object host, out object value, out Exception exception) | ||||||
Attempts to get the value of the property.
| |||||||
void | SetValue (object host, object value) | ||||||
Sets the value of the property or field on the provided host.
| |||||||
void | SetValueAt (object host, object value, object index) | ||||||
Sets the value in a collection at that index, if possible.
| |||||||
void | SetValue< T > (ref T host, object value) | ||||||
Sets the value for the field or property as found on the provided host.
|
Static Public Member Functions | |
static PropertyOrField | Create (PropertyInfo propertyInfo) |
Creates a PropertyOrField container for a provided PropertyInfo. | |
static PropertyOrField | Create (FieldInfo fieldInfo) |
Creates a PropertyOrField container for a provided FieldInfo. | |
static PropertyOrField | Find (Type type, string name) |
Attempts to find a property or field with the given name on a type - will scan public, private, static and instance properties and fields. It's up to the caller to know what do to with that (: | |
static PropertyOrField | TryFind (Type type, string name) |
Attempts to find a property or field with the given name on a type - will scan public, private, static and instance properties and fields. It's up to the caller to know what do to with that (: | |
static implicit | operator PropertyOrField (PropertyInfo prop) |
Implicitly converts a PropertyInfo object to a PropertyOrField. | |
static implicit | operator PropertyOrField (FieldInfo field) |
Implicitly converts a FieldInfo object to a FieldOrField. |
Properties | |
string | Name [get] |
Name of the property or field. | |
Type | Type [get] |
Type of the property or field. | |
bool | CanWrite [get] |
Write access to property or field. | |
bool | CanRead [get] |
Read access to property or field. | |
PropertyOrFieldTypes | MemberType [get] |
Is this a Property or a Field? | |
Type | DeclaringType [get] |
The type on which this property or field is declared. | |
Type | HostingType [get] |
The type from which this property or field is read.
| |
int | AncestralDistance [get] |
Returns the ancestral distance between the DeclaringType and the HostingType (0 if they are the same type) | |
PropertyInfo | PropertyInfo [get] |
the provided prop |
Provides a single storage / representation for a Property or a Field.
PeanutButter.Utils.PropertyOrField.PropertyOrField | ( | PropertyInfo | prop | ) |
Constructs the PropertyOrField around a property.
prop |
PeanutButter.Utils.PropertyOrField.PropertyOrField | ( | PropertyInfo | prop, |
Type | hostingType ) |
Constructs the PropertyOrField around a property, relative to an hosting type (ie, without assuming that the DeclaringType is the hosting type for the property)
prop | |
hostingType |
PeanutButter.Utils.PropertyOrField.PropertyOrField | ( | FieldInfo | field | ) |
Constructs the PropertyOrField around a field.
field |
PeanutButter.Utils.PropertyOrField.PropertyOrField | ( | FieldInfo | field, |
Type | hostingType ) |
Constructs the PropertyOrField around a field.
field | |
hostingType |
|
static |
|
static |
|
static |
Attempts to find a property or field with the given name on a type - will scan public, private, static and instance properties and fields. It's up to the caller to know what do to with that (:
type | |
name |
ArgumentException | thrown when the property or field is not found |
object PeanutButter.Utils.PropertyOrField.GetValue | ( | object | host | ) |
Gets the value of the property or field for the provided host.
host |
Implements PeanutButter.Utils.IPropertyOrField.
object PeanutButter.Utils.PropertyOrField.GetValueAt | ( | object | host, |
object | index ) |
Get the value at the provided index into a collection.
host | |
index |
Implements PeanutButter.Utils.IPropertyOrField.
|
static |
Implicitly converts a FieldInfo object to a FieldOrField.
field |
|
static |
void PeanutButter.Utils.PropertyOrField.SetValue | ( | object | host, |
object | value ) |
Sets the value of the property or field on the provided host.
host | |
value |
Implements PeanutButter.Utils.IPropertyOrField.
void PeanutButter.Utils.PropertyOrField.SetValue< T > | ( | ref T | host, |
object | value ) |
Sets the value for the field or property as found on the provided host.
host | |
value |
T |
Implements PeanutButter.Utils.IPropertyOrField.
void PeanutButter.Utils.PropertyOrField.SetValueAt | ( | object | host, |
object | value, | ||
object | index ) |
Sets the value in a collection at that index, if possible.
host | |
value | |
index |
Implements PeanutButter.Utils.IPropertyOrField.
|
static |
Attempts to find a property or field with the given name on a type - will scan public, private, static and instance properties and fields. It's up to the caller to know what do to with that (:
type | |
name |
bool PeanutButter.Utils.PropertyOrField.TryGetValue | ( | object | host, |
out object | value, | ||
out Exception | exception ) |
Attempts to get the value of the property.
host | |
value | |
exception |
Implements PeanutButter.Utils.IPropertyOrField.
|
get |
Returns the ancestral distance between the DeclaringType and the HostingType (0 if they are the same type)
Implements PeanutButter.Utils.IPropertyOrField.
|
get |
Read access to property or field.
Implements PeanutButter.Utils.IPropertyOrField.
|
get |
Write access to property or field.
Implements PeanutButter.Utils.IPropertyOrField.
|
get |
The type on which this property or field is declared.
Implements PeanutButter.Utils.IPropertyOrField.
|
get |
The type from which this property or field is read.
Implements PeanutButter.Utils.IPropertyOrField.
|
get |
Name of the property or field.
Implements PeanutButter.Utils.IPropertyOrField.
|
get |
Type of the property or field.
Implements PeanutButter.Utils.IPropertyOrField.