Object Hydrator - Big changes afoot.

Since last I posted, I've received an awesome implementation of a fluent interface for Object Hydrator from Scott Monnig.  We've ditched the Attributes and mapping scenarios in favor of some convention and  a fluent interface.

So as before this will get you a single customer:

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

SimpleCustomer customer = hydrator.GetSingle();

The difference here is that SimpleCustomer looks slimmer like this:

        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string Company { get; set; }

        public string Description { get; set; }

        public int Locations { get; set; }

        public DateTime IncorporatedOn { get; set; }

        public Double Revenue { get; set; }

By convention FirstName, fname etc...will use the FirstNameGenerator...and so on.  If there is no infered generator, it will pick one by type.

 If you want to override a value, you do it like this:

            string defaultValue = "Testing123";

 

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

                .WithDefault("Description", defaultValue);

Easy huh?

What if you wanted to override the Company name with a FirstNameGenerator value for some wacky reason?  Piece of cake...

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

            .FromGenerator("Company", new FirstNameGenerator());

            SimpleCustomer customer = hydrator.GetSingle();

Aggregate roots are still being worked on and are in this code they require a little deeper info, but check out the source if you are curious where we're going with those.

Please check out the source at http://objecthydrator.codeplex.com and peruse the tests to see more examples.  I'll be doing a deeper write up as we make that first .1 release and will include the source. 

Thanks a ton to Scott and as always feel free to let me know what you think.

Published Monday, October 05, 2009 12:52 PM by ryansjedi
Filed under: , ,

Comments

# Object Hydrator - Big changes afoot.@ Monday, October 05, 2009 8:34 PM

DotNetBurner - burning hot .net content

Leave a Comment

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