using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Web.Core { class Switch : List>> { public void Add(Predicate checker, Func calculator) { this.Add(new KeyValuePair>(checker, calculator)); } public void Add(bool checkResult, Func calculator) { this.Add(() => checkResult, calculator); } public TResult Value { get { return this.Single(kvp => kvp.Key(), () => { throw new FLocalException("Not found"); }).Value(); } } } }