public ThenItExpression <T> If(Predicate <IContext> predicate) { return(new InstanceExpression <T>(i => { var theCase = new InstanceCase { Instance = i, Predicate = predicate }; _parent._cases.Add(theCase); })); }
protected override object build(Type pluginType, BuildSession session) { // Find the first InstanceCase that matches the BuildSession/IContext InstanceCase instanceCase = _cases.Find(c => c.Predicate(session)); // Use the Instance from the InstanceCase if it exists, // otherwise, use the "default" Instance instance = instanceCase == null ? _default : instanceCase.Instance; // delegate to the chosen Instance return(instance.Build(pluginType, session)); }