private static void NotifyPropertyChanged( EditContext editContext, object instance, string propertyName) { if (GetFieldStateMethod == null) { GetFieldStateMethod = editContext.GetType().GetMethod( "GetFieldState", BindingFlags.NonPublic | BindingFlags.Instance); } var fieldIdentifier = new FieldIdentifier(instance, propertyName); object fieldState = GetFieldStateMethod.Invoke(editContext, new object[] { fieldIdentifier }); if (IsModifiedProperty == null && fieldState != null) { IsModifiedProperty = fieldState.GetType().GetProperty( "IsModified", BindingFlags.Public | BindingFlags.Instance); object originalIsModified = IsModifiedProperty?.GetValue(fieldState); editContext.NotifyFieldChanged(fieldIdentifier); IsModifiedProperty?.SetValue(fieldState, originalIsModified); } }
private static void EnsureGetFieldStateMethod(EditContext editContext) { #if (NETSTANDARD2_0 || NETSTANDARD2_1) var methodname = "GetFieldState"; #elif (NET5_0) var methodname = "GetOrAddFieldState"; #endif if (GetFieldStateMethod == null) { GetFieldStateMethod = editContext.GetType().GetMethod(methodname, BindingFlags.NonPublic | BindingFlags.Instance); } }