[DevExpress Support Team: CLONED FROM T1003220: Blazor - How to implement a Progress Bar in Grid List Editor cells]
Hi,
This is pretty cool !
May propose something more generic that works with all objects.
I saw in this ticket that the performance of XPMemberInfo.GetValue and XPMemberInfo.SetValue may be better than the performance of reflection classes (PropertyInfo, FieldInfo) because XPMemberInfo makes special accessors to properties by ILGenerator class.
So should we use XPMemberInfo (commented part) ? Both solution are working just curious about performance here.
C#[PropertyEditor(typeof(int), TestProgressBusinessObject.ProgressPropertyAlias, false)]
public class ProgressBarEditor : BlazorPropertyEditorBase, IComplexViewItem
{
private BlazorApplication application;
private IObjectSpace objectSpace;
public ProgressBarEditor(Type objectType, IModelMemberViewItem model) : base(objectType, model) { }
void IComplexViewItem.Setup(IObjectSpace objectSpace, XafApplication application) {
this.objectSpace = objectSpace;
this.application = (BlazorApplication)application;
}
protected override IComponentAdapter CreateComponentAdapter() => new ProgressBarAdapter(new ProgressBarModel());
protected override RenderFragment CreateViewComponentCore(object dataContext)
{
//var testProgressBusinessObject = (TestProgressBusinessObject)dataContext;
//XPClassInfo classInfo = ((XPObjectSpace)objectSpace).Session.GetClassInfo(dataContext.GetType());
//var value = classInfo.GetMember(PropertyName).GetValue(dataContext);
var value = this.ObjectTypeInfo.FindMember(PropertyName).GetValue(dataContext);
ProgressBarModel progressBarModel = new ProgressBarModel() { Value = (int)value };
return ProgressBarRenderer.Create(progressBarModel);
}
}