public static CseObject Ternary(CseObject cond, CseObject truePart, CseObject falsePart) {
bool? condBool = cond.Value as bool?;
if (condBool != null)
return condBool.Value ? truePart : falsePart;
else {
MethodInfo mi = cond.Value.GetType().GetMethod(OpOverloadNames.TRUE);
if (mi != null)
return new CseObject(cond.Value.GetType().InvokeMember(OpOverloadNames.TRUE, OpOverloadNames.Flags, null, CsEval.evalEnvironment, new object[] { cond.Value }));
else
return null;
//TODO: throw new logic exception for this
}
}
}