Object Hydrator Fluent Interface Now Type Safe

Thanks to a patch submission by Hakan Forss the Object Hydrator Fluent Interface is now type safe, with all the magic strings removed. The standard inferences are still there so you could do most of your generation without ever using the advanced methods. 

The new syntax for the example in my last post looks like this:

            string defaultValue = "Testing123";

            Hydrator<SimpleCustomer> hydrator = new Hydrator<SimpleCustomer>()

                .With(x => x.Description, defaultValue);

            SimpleCustomer customer = hydrator.GetSingle();

For the second example where you wanted to override the Company name generation, you actually have two choices:

            Hydrator<SimpleCustomer> hydrator = new Hydrator<SimpleCustomer>()

            .WithLastName(x => x.Company);

            SimpleCustomer customer = hydrator.GetSingle();

 

            Hydrator<SimpleCustomer> hydrator2 = new Hydrator<SimpleCustomer>()

            .With(x => x.Company, new FirstNameGenerator());

            SimpleCustomer customer2 = hydrator.GetSingle();

Just kind of depends on what your style is...both work the same.

More to come as we creep on on a release.  Feel free to check this version (.5) out at  http://objecthydrator.codeplex.com
*fixed url

 

Ryan

 

 

 

Published Monday, October 12, 2009 11:58 AM by ryansjedi
Filed under: , ,

Comments

# re: Object Hydrator Fluent Interface Now Type Safe@ Monday, October 12, 2009 5:50 PM

That address doesn't seem to work.

This will be very useful, BTW.

by uiawefhawiu

# re: Object Hydrator Fluent Interface Now Type Safe@ Monday, October 12, 2009 6:51 PM

Ooops fixed it...should be .com

objecthydrator.codeplex.com

Thanks.  I hope it helps everyone out as much as the early version has helped me.  I'm in the process of converting my current "dog fooding" of this to the new version.

Leave a Comment

(required) 
(required) 
(optional)
(required)