Skip to content

Instantly share code, notes, and snippets.

@FransBouma
Created March 24, 2014 08:53
Show Gist options
  • Save FransBouma/9736633 to your computer and use it in GitHub Desktop.
Save FransBouma/9736633 to your computer and use it in GitHub Desktop.
Even with 20+ years of development experience, Monday mornings are hard...
object newValueInType = newValue;
string newValueAsString = newValue as string;
if(type == typeof(DateTimeOffset))
{
newValueInType = DateTimeOffset.Parse(newValueAsString);
}
if(type == typeof(Guid))
{
newValueInType = Guid.Parse(newValueAsString);
}
if(type == typeof(TimeSpan))
{
newValueInType = TimeSpan.Parse(newValueAsString);
}
else
{
newValueInType = Convert.ChangeType(newValue, type);
}
_defaultsPerType[type] = newValueInType;
@laurenceabas
Copy link

Cant agree more with you about Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment