您觉得以下 C# 代码清晰易读吗?
private bool CanExecuteAdd(string parameter) {
return
this.Script == null ? false
: parameter == "Step" ? true
: parameter == "Element" ? this.ElementSelectedInLibrary != null && this.SelectedStep != null
: parameter == "Choice" ? this.SelectedElement != null
: parameter == "Jump" ? this.SelectedStep != null
: parameter == "Conditional jump" ? false
: false.Throw("Unknown Add parameter {0} in XAML.".F(parameter));
}
其中 Throw 定义为:
public static T Throw<T>(this T ignored, string message) {
throw new Exception(message);
}
我知道这不是惯用的 C#。但是,您第一眼或第二眼就能理解它吗?还是我走得太远了?