public void RegisterMessage(Accessor accessor, NotificationMessage notificationMessage) { notificationMessage.AddAccessor(accessor); notificationMessage.AddSubstitution(TemplateValue.For(FIELD, LocalizationManager.GetText(accessor.InnerProperty))); _messages.Fill(notificationMessage); }
public void Validate(ValidationContext context) { var value1 = _property1.GetValue(context.Target); var value2 = _property2.GetValue(context.Target); if (value1 == null && value2 == null) { return; } if (_type == typeof(string)) { var str1 = value1 as string; var str2 = value2 as string; if (str1.IsEmpty() && str2.IsEmpty()) { return; } } if (Equals(value1, value2)) { return; } _accessors.Each(x => { var values = new[] { TemplateValue.For(Field1, _property1.Name), TemplateValue.For(Field2, _property2.Name) }; context .Notification .RegisterMessage(x, Token, values); }); }
public NotificationMessage AddSubstitution(string key, string value) { return(AddSubstitution(TemplateValue.For(key, value))); }