public void DryRun(AmazonEC2Client client, AmazonEC2Request request, ref DryRunResponse response)
            {
                response.IsSuccessful = false;

                SetDryRun(request, true);
                try
                {
                    Method.Invoke(client, new object[] { request });
                    // If no exception thrown, consider this a failure
                    response.Message = "Unrecognized service response for the dry-run request.";
                }
                catch (Exception invokeException)
                {
                    Exception actualException = invokeException.InnerException;
                    AmazonEC2Exception ec2e = actualException as AmazonEC2Exception;

                    response.Message = actualException.Message;
                    if (ec2e != null)
                    {
                        response.IsSuccessful = ec2e.StatusCode == HttpStatusCode.PreconditionFailed;
                        response.ResponseMetadata = new ResponseMetadata
                        {
                            RequestId = ec2e.RequestId
                        };
                    }

                    if (!response.IsSuccessful)
                        response.Error = actualException;
                }
                finally
                {
                    SetDryRun(request, false);
                }
            }
 private void SetDryRun(AmazonEC2Request request, bool value)
 {
     if (value)
         ((Amazon.Runtime.Internal.IAmazonWebServiceRequest )request).AddBeforeRequestHandler(SetDryRunParameterCallback);
     else
         ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)request).RemoveBeforeRequestHandler(SetDryRunParameterCallback);
 }
 private void SetDryRun(AmazonEC2Request request, bool value)
 {
     if (value)
         request.BeforeRequestEvent += SetDryRunParameterCallback;
     else
         request.BeforeRequestEvent -= SetDryRunParameterCallback;
 }
 private void SetDryRun(AmazonEC2Request request, bool value)
 {
     if (value)
         ((Amazon.Runtime.Internal.IAmazonWebServiceRequest )request).AddBeforeRequestHandler(SetDryRunParameterCallback);
     else
         ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)request).RemoveBeforeRequestHandler(SetDryRunParameterCallback);
 }
            public void DryRun(AmazonEC2Client client, AmazonEC2Request request, ref DryRunResponse response)
            {
                response.IsSuccessful = false;

                SetDryRun(request, true);
                try
                {
                    Method.Invoke(client, new object[] { request });
                    // If no exception thrown, consider this a failure
                    response.Message = "Unrecognized service response for the dry-run request.";
                }
                catch (Exception invokeException)
                {
                    Exception actualException = invokeException.InnerException;
                    AmazonEC2Exception ec2e = actualException as AmazonEC2Exception;

                    response.Message = actualException.Message;
                    if (ec2e != null)
                    {
                        response.IsSuccessful = ec2e.StatusCode == HttpStatusCode.PreconditionFailed;
                        response.ResponseMetadata = new ResponseMetadata
                        {
                            RequestId = ec2e.RequestId
                        };
                    }

                    if (!response.IsSuccessful)
                        response.Error = actualException;
                }
                finally
                {
                    SetDryRun(request, false);
                }
            }
 private void SetDryRun(AmazonEC2Request request, bool value)
 {
     if (value)
     {
         request.BeforeRequestEvent += SetDryRunParameterCallback;
     }
     else
     {
         request.BeforeRequestEvent -= SetDryRunParameterCallback;
     }
 }
        /// <summary>
        /// Checks whether you have the required permissions for the action, without actually making the request.
        /// </summary>
        /// <param name="request">Request to do a dry run of.</param>
        /// <returns>Result of the dry run.</returns>
        public DryRunResponse DryRun(AmazonEC2Request request)
        {
            DryRunResponse response = new DryRunResponse { IsSuccessful = false };

            if (request == null)
            {
                response.Message = "Request must not be null";
                return response;
            }

            DryRunInfo dryRunInfo;
            Type requestType = request.GetType();
            if (!MethodCache.TryGetValue(requestType, out dryRunInfo) || dryRunInfo == null)
            {
                response.Message = "Unrecognized request";
                return response;
            }

            dryRunInfo.DryRun(this, request, ref response);
            return response;
        }
        /// <summary>
        /// Checks whether you have the required permissions for the action, without actually making the request.
        /// </summary>
        /// <param name="request">Request to do a dry run of.</param>
        /// <returns>Result of the dry run.</returns>
        public DryRunResponse DryRun(AmazonEC2Request request)
        {
            DryRunResponse response = new DryRunResponse { IsSuccessful = false };

            if (request == null)
            {
                response.Message = "Request must not be null";
                return response;
            }

            DryRunInfo dryRunInfo;
            Type requestType = request.GetType();
            if (!MethodCache.TryGetValue(requestType, out dryRunInfo) || dryRunInfo == null)
            {
                response.Message = "Unrecognized request";
                return response;
            }

            dryRunInfo.DryRun(this, request, ref response);
            return response;
        }