public object?Create(IBindingRequest bindingRequest) { foreach (var constructor in constructors.Where(i => i.Value.CanCreate(bindingRequest.Clone()))) { try { return(constructor.Value.Create(bindingRequest.Clone())); } catch (IocException) { // try the next constructor until one works } } // if we get to here then we failed. So we need to repeat the first try to let // the exception bubble up. return(constructors[0].Value.Create(bindingRequest)); }
public bool CanCreate(IBindingRequest bindingRequest) => constructors.Any(i => i.Value.CanCreate(bindingRequest.Clone()));