Skip to content

bubdm/DynamicNotifyPropertyChanged

 
 

Repository files navigation

Nuget

This library allows you to create types at runtime that implement INotifyPropertyChanged interface. Each property calls OnPropertyChanged when its value is changed.

Creating Type

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.

Initializing Created Type

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.

Getting Property Value

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)

Setting Property Value

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.

About

Create type that implement INotifyPropertyChanged at runtime.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C# 100.0%