Example #1
0
        public void RegisterMessage(Accessor accessor, NotificationMessage notificationMessage)
        {
            notificationMessage.AddAccessor(accessor);
            notificationMessage.AddSubstitution(TemplateValue.For(FIELD, LocalizationManager.GetText(accessor.InnerProperty)));

            _messages.Fill(notificationMessage);
        }
Example #2
0
        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);
            });
        }
Example #3
0
 public NotificationMessage AddSubstitution(string key, string value)
 {
     return(AddSubstitution(TemplateValue.For(key, value)));
 }