CSE.Exps.CondExp.Ternary C# (CSharp) 메소드

Ternary() 공개 정적인 메소드

Parses ternary expressions
public static Ternary ( CseObject cond, CseObject truePart, CseObject falsePart ) : CseObject
cond CseObject Conditional to test
truePart CseObject Expression to return if condition is true
falsePart CseObject Expression to return if condition is false
리턴 CseObject
		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 
			}
		}
	}