This project is read-only.

Generating a property which depends on another

Sep 10, 2014 at 1:37 AM
Maybe I'm just trying to get too tricky here, but I'm wondering whether it's possible to use AutoPoco to fill out a property on an object which depends on the value of another property.

For example I'd like End to always be later than Start in the following:
class Span
    public DateTime Start { get; set; }
    public DateTime End { get; set; }
The only way I can imagine it happening right now is having some kind of post object creation step before the object is given to the user. A more general form of that might be to have a fluent interface for creating "layers" of initialisation like so:
    var factory = AutoPocoContainer.Configure(builder =>
               .Setup(span => span.Start).Use<DateTimeSource>(new DateTime(1900, 1, 1), new DateTime(2000, 1, 1))
               .Setup(span => span.End).Use<DateTimeSource>(span => span.Start, _ => new DateTime(2000, 1, 1));
Is there some way to do this already that I've missed? Any other ideas? Or am I just trying to make the library do something it isn't meant to do?