This library allows you to create types at runtime that implement INotifyPropertyChanged interface. Each property calls OnPropertyChanged when its value is changed.
Dynamic class can be created by calling:
DynamicNotifyPropertyChangedClassFactory.CreateType(DynamicProperty[] properties)DynamicProperty contains two properties:
- Name
- Type
You must ensure that duplicate properties are not present. Created type is cached. If you pass same set of dynamic properties (even in different order) new type will not be created.
You can create new instance by calling:
DynamicNotifyPropertyChangedClassFactory.CreateTypeInstance(Type type)
Alternatively, you can create Func that returns new instance by calling:
DynamicNotifyPropertyChangedClassFactory.CreateTypeFactory(Type type)Both methods use caching and Reflection.Emit internally for better performance.
You can get property value by calling:
ObjectExtensions.GetPropertyValue<T>(this object source, string propertyName)Alternatively, you can create Func that gets property value from object by calling:
TypeExtensions.GetPropertyGetter(Type type, string propertyName)You can set property value by calling:
ObjectExtensions.SetPropertyValue<T>(this object source, string propertyName, T value)Alternatively, you can create Func that sets property value on object by calling:
TypeExtensions.GetPropertySetter(Type type, string propertyName)All methods described above use caching and compiled expressions for better performance.