当前位置: 首页>>代码示例>>C#>>正文


C# Snippet.GetType方法代码示例

本文整理汇总了C#中Snippet.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Snippet.GetType方法的具体用法?C# Snippet.GetType怎么用?C# Snippet.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Snippet的用法示例。


在下文中一共展示了Snippet.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EditSnippetWithHttpInfo

        /// <summary>
        ///  Updates an existing snippet with the specified ID
        /// </summary>
        /// <param name="id">ID of snippet to update</param> 
        /// <param name="data"></param> 
        /// <returns>ApiResponse of SnippetResponseSingle</returns>
        public ApiResponse< SnippetResponseSingle > EditSnippetWithHttpInfo (long? id, Snippet data)
        {
            
            // verify the required parameter 'id' is set
            if (id == null)
                throw new ApiException(400, "Missing required parameter 'id' when calling SquiggleApi->EditSnippet");
            
            // verify the required parameter 'data' is set
            if (data == null)
                throw new ApiException(400, "Missing required parameter 'data' when calling SquiggleApi->EditSnippet");
            
    
            var path_ = "/snippets/{id}";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            Object postBody = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/json"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/json"
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
            if (httpHeaderAccept != null)
                headerParams.Add("Accept", httpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (id != null) pathParams.Add("id", Configuration.ApiClient.ParameterToString(id)); // path parameter
            
            
            
            
            if (data.GetType() != typeof(byte[]))
            {
                postBody = Configuration.ApiClient.Serialize(data); // http body (model) parameter
            }
            else
            {
                postBody = data; // byte array
            }

            // authentication (jwt) required
            
            var apiKeyValue = Configuration.GetApiKeyWithPrefix("Authorization");
            if (!String.IsNullOrEmpty(apiKeyValue))
            {
                headerParams["Authorization"] = apiKeyValue;
            }
            
    
            // make the HTTP request
            IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, 
                Method.PATCH, queryParams, postBody, headerParams, formParams, fileParams,
                pathParams, httpContentType);

            int statusCode = (int) response.StatusCode;
    
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling EditSnippet: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling EditSnippet: " + response.ErrorMessage, response.ErrorMessage);
    
            return new ApiResponse<SnippetResponseSingle>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (SnippetResponseSingle) Configuration.ApiClient.Deserialize(response, typeof(SnippetResponseSingle)));
            
        }
开发者ID:squiggle-dev,项目名称:squiggle-csharpnet45,代码行数:84,代码来源:SquiggleApi.cs

示例2: EditSnippetWithHttpInfo

        /// <summary>
        ///  Updates an existing snippet with the specified ID
        /// </summary>
        /// <exception cref="Squiggle.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="id">ID of snippet to update</param>
        /// <param name="data"></param>
        /// <returns>ApiResponse of Snippet</returns>
        public ApiResponse<Snippet> EditSnippetWithHttpInfo(long? id, Snippet data)
        {
            // verify the required parameter 'id' is set
            if (id == null)
                throw new ApiException(400, "Missing required parameter 'id' when calling DefaultApi->EditSnippet");
            // verify the required parameter 'data' is set
            if (data == null)
                throw new ApiException(400, "Missing required parameter 'data' when calling DefaultApi->EditSnippet");

            var localVarPath = "/snippets/{id}";
            var localVarPathParams = new Dictionary<String, String>();
            var localVarQueryParams = new Dictionary<String, String>();
            var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var localVarFormParams = new Dictionary<String, String>();
            var localVarFileParams = new Dictionary<String, FileParameter>();
            Object localVarPostBody = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
            if (localVarHttpHeaderAccept != null)
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (id != null) localVarPathParams.Add("id", Configuration.ApiClient.ParameterToString(id)); // path parameter
            if (data != null && data.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(data); // http body (model) parameter
            }
            else
            {
                localVarPostBody = data; // byte array
            }

            // authentication (jwt) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Authorization")))
            {
                localVarHeaderParams["Authorization"] = Configuration.GetApiKeyWithPrefix("Authorization");
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
                Method.PATCH, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int) localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("EditSnippet", localVarResponse);
                if (exception != null) throw exception;
            }

            return new ApiResponse<Snippet>(localVarStatusCode,
                localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (Snippet) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Snippet)));
        }
开发者ID:squiggle-dev,项目名称:squiggle-csharp,代码行数:74,代码来源:DefaultApi.cs


注:本文中的Snippet.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。