public IEnumerable <OutputMember> Invoke() { if (!Inputs.AllReady()) { throw new InvalidOperationException("The operation is not ready for invocation."); } var handler = CreateInstance(_ownerType, Resolver); var bindingResults = from kv in _parameterBinders let param = kv.Key let binder = kv.Value select binder.IsEmpty ? BindingResult.Success(param.DefaultValue) : binder.BuildObject(); var parameters = GetParameters(bindingResults); var result = _method.Invoke(handler, parameters.ToArray()); // note this is only temporary until we implement out and ref support... if (_method.OutputMembers.Any()) { return(new[] { new OutputMember { Member = _method.OutputMembers.Single(), Value = result.Single() } }); } return(new OutputMember[0]); }
void CheckInputs() { if (Inputs.AllReady()) { return; } var notReady = Inputs.WhosNotReady(); throw new InvalidOperationException( $"'{Method.Owner.Name}.{Method.Name} could not execute. " + $"These members have not been provided: {notReady.Select(x => x.Name).JoinString(", ")}"); }
public Task <IEnumerable <OutputMember> > InvokeAsync() { if (!Inputs.AllReady()) { var notReady = Inputs.WhosNotReady(); throw new InvalidOperationException( $"'{_method.Owner.Name}.{_method.Name} could not execute. " + $"These members have not been provided: {notReady.Select(x => x.Name).JoinString(", ")}"); } var handler = CreateInstance(_ownerType, Resolver); var bindingResults = from kv in _parameterBinders let param = kv.Key let binder = kv.Value select binder.IsEmpty ? BindingResult.Success(param.DefaultValue) : binder.BuildObject(); var parameters = GetParameters(bindingResults); return(_invoker.Invoke(handler, parameters.ToArray())); }