private object CheckRawType(object value)
{
// bool|enum|flags|uint|int|int64|string|timeSpan
if (this.Type == "bool" && value is bool)
{
return value;
}
if (this.Type == "enum" && value is long)
{
return value;
}
if (this.Type == "enum" && value is int)
{
return Convert.ToInt64(value);
}
if (this.Type == "enum" && value is string)
{
return Parse((string)value);
}
// TODO: is this needed?
if (this.Type == "flags" && value is long)
{
return value;
}
if (this.Type == "flags" && value is string)
{
return Parse((string)value);
}
if (this.Type == "uint" && value is uint)
{
return value;
}
if (this.Type == "uint" && value is int)
{
return Convert.ToUInt32(value);
}
// IMPORTANT: site id
if (this.Type == "uint" && value is long)
{
return Convert.ToUInt32(value);
}
if (this.Type == "int" && value is int)
{
return value;
}
if (this.Type == "int64" && value is long)
{
return value;
}
if (this.Type == "string" && value is string)
{
return value;
}
if (this.Type == "timeSpan" && value is TimeSpan)
{
return value;
}
throw new InvalidCastException();
}
}