public IBoilerplateContext <TResult> AndGet <TResult>(Func <IBoilerplateContext, T, TResult> useType) { var downgradedContext = DowngradeToInitial(); var timingContext = new TimingContext(this.bundle.TimingVisibility); var access = this.bundle.Access; var response = access.TryAccess <T, TResult>(this.identity, instance => { return(this.bundle.Errors.DoInContext <TResult>(_ => { TResult result = default(TResult); timingContext.OpenAs(this.bundle.Visibility, () => result = useType(downgradedContext, instance)); return result; })); }); if (!response.IsSuccess) { throw new OperationWasNotSuccessfulException(response.Result); } var timings = timingContext.EnqueueElapsed(this.context.CallTimings); return(new ResultBoilerplateContext <TResult>(this.bundle, this.identity, this.contractBundle, response.Content, timings)); }
public IBoilerplateContext AndDo(Action <IBoilerplateContext, T> useType) { var downgradedContext = DowngradeToInitial(); var timingContext = new TimingContext(this.bundle.TimingVisibility); var access = this.bundle.Access; var response = access.TryAccess <T>(this.identity, instance => { this.bundle.Errors.DoInContext(_ => { timingContext.OpenAs(this.bundle.Visibility, () => useType(downgradedContext, instance)); }); }); if (!response.IsSuccess) { throw new OperationWasNotSuccessfulException(response.Result); } var timings = timingContext.EnqueueElapsed(this.context.CallTimings); return(new InitialBoilerplateContext <ContractContext>(this.bundle, this.identity, this.contractBundle, timings)); }