public object Execute(ExecutorContext context) { System.IO.MemoryStream _AgentProfileStream = null; try { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.CodeGuruProfiler.Model.PostAgentProfileRequest(); if (cmdletContext.AgentProfile != null) { _AgentProfileStream = new System.IO.MemoryStream(cmdletContext.AgentProfile); request.AgentProfile = _AgentProfileStream; } if (cmdletContext.ContentType != null) { request.ContentType = cmdletContext.ContentType; } if (cmdletContext.ProfileToken != null) { request.ProfileToken = cmdletContext.ProfileToken; } if (cmdletContext.ProfilingGroupName != null) { request.ProfilingGroupName = cmdletContext.ProfilingGroupName; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); } finally { if (_AgentProfileStream != null) { _AgentProfileStream.Dispose(); } } }
private Amazon.CodeGuruProfiler.Model.PostAgentProfileResponse CallAWSServiceOperation(IAmazonCodeGuruProfiler client, Amazon.CodeGuruProfiler.Model.PostAgentProfileRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon CodeGuru Profiler", "PostAgentProfile"); try { #if DESKTOP return(client.PostAgentProfile(request)); #elif CORECLR return(client.PostAgentProfileAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }