Open mikila85 opened 9 years ago
Ok,
i managed to solve this (if anyone ever needs it) by creating an attribute:
[Hydrator(Kind="email")]
public string ElectronicMail { get; set; }
public class HydratorAttribute : Attribute
{
public string Kind;
}
and changing the mapping to match:
Add(new Map<string>()
.Matching(info =>
{
HydratorAttribute hydratorType = info.GetCustomAttributes(typeof(HydratorAttribute), false).Cast<HydratorAttribute>().FirstOrDefault();
return hydratorType != null && hydratorType.Kind == "email";
})
.Using(new EmailAddressGenerator()));
I ended up not doing Attributes just due to the clutter they tend to gather on classes. I opted for configuring it in the Hyrdrator. It was just a personal choice really.
Hi, arriving to you from your original post at: http://stackoverflow.com/questions/1413342/are-there-any-tools-to-populate-class-properties-with-random-data
i tried todo the same thing and to create this project until i found yours, the problem is i still cant find the use of attributes(in class) in order to determine the type of the field.
am i missing it or it got neglected on the way?
p.s. What worked was calling the Name as "EmailAddress" .. but the name is Email .. i tried:
[Attribute("EmailAddress")] public string Email{ get; set; }
[EmailAddress] public string Email{ get; set; }
[Hydrator("EmailAddress")] public string Email{ get; set; }
please help.