Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Going back to origins. #9

Open
mikila85 opened this issue Aug 19, 2015 · 2 comments
Open

Going back to origins. #9

mikila85 opened this issue Aug 19, 2015 · 2 comments

Comments

@mikila85
Copy link

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.

@mikila85
Copy link
Author

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()));

@PrintsCharming
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants