I have a domain model object which has properties of type System.DateTimeOffset. I\'m using a database which doesn\'t support this type natively, so I\'m planning to store i
public void SetPropertyValue(object component, int property, object value)
I have code that implements DateTime from two int fields.
The code essentially is a switch on property (0 being date, 1 being time, in my case) and at the end of each case statement the component object is reassigned a new DateTime instance.
property = 0 (Date):
// code to calculate year, month, day from object value
DateTime dt = (DateTime)component;
dt = new DateTime(year, month, day, dt.Hour, dt.Minute, dt.Second);
property = 1 (Time):
// code to calculate hours, minutes, seconds from object value
DateTime dt = (DateTime)component;
dt = new DateTime(dt.Year, dt.Month, dt.Day, hours, minutes, seconds);
No idea if this is good / bad, but it works for me (aka I have no problem changing what component points to, ref or not).