What is SmartDate.GetEmptyValue(bool emptyIsMin) for?

What is SmartDate.GetEmptyValue(bool emptyIsMin) for?

Old forum URL: forums.lhotka.net/forums/t/2891.aspx


david.wendelken posted on Wednesday, May 16, 2007

What is this method in SmartDate for?  I confess, it doesn't make a lick of sense to me!

EmptyValue is a public enumeration, so I could reference it directly. 

How/why would it be used?


private
static EmptyValue GetEmptyValue(bool emptyIsMin)
{

if (emptyIsMin)
    return EmptyValue.MinValue;
else
    return EmptyValue.MaxValue;

}

Brian Criswell replied on Wednesday, May 16, 2007

Quite literally, it tells you what the empty value is.  So if you have an "empty" SmartDate, it is using that real value internally.  The reason it is switchable is for sorting persons.

david.wendelken replied on Wednesday, May 16, 2007

Brian Criswell:
Quite literally, it tells you what the empty value is.  So if you have an "empty" SmartDate, it is using that real value internally.  The reason it is switchable is for sorting persons.

If it were using the internal, private variable to answer the question, I would agree with you.

But the answer is dependent upon the parameter you pass in, not the way the object is set up.  It's static, anyway.  It only tells it what you tell it to tell you, which seems sort of pointless. :)

Brian Criswell replied on Thursday, May 17, 2007

It keeps a piece of logic in only one place.  The result of this method is used in three constructors and date/string conversion methods.  If the static method was not used, you would have that logic in 5 different places.

Copyright (c) Marimer LLC