Sorry guys. I configured it the way NHibernate groups I found said to and
it did not work. In fact, I saw Craig's post over there. According to
several people, in addition to the code (Craig's looks right to me) you have
to add the following to the application/web config:
<nhv-configuration>
<property
name="message_interpolator_class">OnpointConnect.Core.NHibernate.CustomMessa
geInterpolator, OnpointConnect.Core</property>
</nhv-configuration>
Unfortunately, it still does not work.
Anyway, I was not 100% on where Fluent took over the configuration so I was
concerned that I was supposed to configure something in Fluent instead. It
would appear I was wrong. I am going to go get the NHibernate source and
figure it out from there.
Thank you
From: [email protected]
[mailto:[email protected]] On Behalf Of Martin Hornagold
Sent: Wednesday, May 27, 2009 5:47 AM
To: [email protected]
Subject: [fluent-nhib] Re: Using a Custom Message Interpolator
No its all to do with NHibernate.Validator by the looks of it.
I think you would be best trying that group Craig.
From: [email protected]
[mailto:[email protected]] On Behalf Of James Gregory
Sent: 27 May 2009 11:45
To: [email protected]
Subject: [fluent-nhib] Re: Using a Custom Message Interpolator
Does this have anything to do with fluent nhibernate? I'm not seeing any FNH
stuff in there.
On Wed, May 27, 2009 at 10:39 AM, Craig van Nieuwkerk <[email protected]>
wrote:
I asked the same question in the nhibernate message group. Here is my
latest test code that doesn't work. If someone see's the problem it
will help us all.
using NHibernate.Validator.Cfg;
using Environment = NHibernate.Validator.Cfg.Environment;
namespace TestValidator
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestValidator()
{
var customer = new Customer();
ClassValidator classValidator = new
ClassValidator(customer.GetType());
InvalidValue[] validationMessages =
classValidator.GetInvalidValues(customer);
Assert.IsTrue(validationMessages.Length == 1);
Assert.IsTrue(validationMessages[0].Message == "may not be
null or empty");
}
[TestMethod]
public void TestCustomInterpolator()
{
ValidatorEngine ve = new ValidatorEngine();
NHVConfiguration nhvc = new NHVConfiguration();
nhvc.Properties[Environment.MessageInterpolatorClass] =
typeof(CustomMessageInterpolator).AssemblyQualifiedName;
ve.Configure(nhvc);
var customer = new Customer();
ClassValidator classValidator = new
ClassValidator(customer.GetType());
InvalidValue[] validationMessages =
classValidator.GetInvalidValues(customer);
Assert.IsTrue(validationMessages.Length == 1);
Assert.IsTrue(validationMessages[0].Message ==
"CustomMessageInterpolator");
}
}
public class Customer
{
public virtual int CustomerId { get; set; }
[NotNullNotEmpty]
public string CustomerName { get; set; }
}
public class CustomMessageInterpolator : IMessageInterpolator
{
public CustomMessageInterpolator()
{
}
public string Interpolate(string message, IValidator validator,
IMessageInterpolator defaultInterpolator)
{
return "CustomMessageInterpolator";
}
}
}
On Wed, May 27, 2009 at 6:19 AM, tjbsb <[email protected]> wrote:
>
> How do I go about configuring a custom message interpolator?
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---