public object MarshallToClr(object bikeObject)
{
if (bikeObject == null || !(bikeObject is BikeObject))
return bikeObject;
if (bikeObject is BikeBoolean)
return ((BikeBoolean)bikeObject).Value;
if (bikeObject is BikeString)
{
string value = ((BikeString) bikeObject).Value;
return value.Length == 1 ? (object)value[0] : value;
}
if (bikeObject is BikeNumber)
{
return ((BikeNumber) bikeObject).Value;
}
if (bikeObject is BikeArray)
{
var ba = (BikeArray)bikeObject;
var arr = new object[ba.Value.Count];
for (int i = 0; i < arr.Length; i++)
{
arr[i] = MarshallToClr(ba.Value[i]);
}
return arr;
}
return bikeObject;
}