ApplyOptionalParms() public static method

Using reflection to apply optional parameters to the request. If the optonal parameters are null then we will just return the request as is.
public static ApplyOptionalParms ( object request, object optional ) : object
request object The request.
optional object The optional parameters.
return object
Beispiel #1
0
                   /// <param name="optional">Optional paramaters.</param>        /// <returns>ListStepThumbnailsResponseResponse</returns>
                   public static ListStepThumbnailsResponse List(ToolResultsService service, string projectId, string historyId, string executionId, string stepId, ThumbnailsListOptionalParms optional = null)
                   {
                       try
                       {
                           // Initial validation.
                           if (service == null)
                           {
                               throw new ArgumentNullException("service");
                           }
                           if (projectId == null)
                           {
                               throw new ArgumentNullException(projectId);
                           }
                           if (historyId == null)
                           {
                               throw new ArgumentNullException(historyId);
                           }
                           if (executionId == null)
                           {
                               throw new ArgumentNullException(executionId);
                           }
                           if (stepId == null)
                           {
                               throw new ArgumentNullException(stepId);
                           }

                           // Building the initial request.
                           var request = service.Thumbnails.List(projectId, historyId, executionId, stepId);

                           // Applying optional parameters to the request.
                           request = (ThumbnailsResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                           // Requesting data.
                           return request.Execute();
                       }
                       catch (Exception ex)
                       {
                           throw new Exception("Request Thumbnails.List failed.", ex);
                       }
                   }
        /// <param name="optional">Optional paramaters.</param>        /// <returns>EmptyResponse</returns>
        public static Empty Delete(CloudRuntimeConfigService service, string name, VariablesDeleteOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                    throw new ArgumentNullException("service");
                if (name == null)
                    throw new ArgumentNullException(name);

                // Building the initial request.
                var request = service.Variables.Delete(name);

                // Applying optional parameters to the request.                
                request = (VariablesResource.DeleteRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return request.Execute();
            }
            catch (Exception ex)
            {
                throw new Exception("Request Variables.Delete failed.", ex);
            }
        }