예제 #1
0
 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));
 }
예제 #2
0
 public bool CanCreate(IBindingRequest bindingRequest) =>
 constructors.Any(i => i.Value.CanCreate(bindingRequest.Clone()));