• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Model.Pet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IO.Swagger.Model.Pet的典型用法代码示例。如果您正苦于以下问题:C# Pet类的具体用法?C# Pet怎么用?C# Pet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Pet类属于IO.Swagger.Model命名空间,在下文中一共展示了Pet类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Init

        public void Init()
        {
            // create pet
            Pet p = new Pet();
            p.Id = petId;
            p.Name = "Csharp test";
            p.Status = "available";
            // create Category object
            Category category = new Category();
            category.Id = 56;
            category.Name = "sample category name2";
            List<String> photoUrls = new List<String>(new String[] {"sample photoUrls"});
            // create Tag object
            Tag tag = new Tag();
            tag.Id = petId;
            tag.Name = "sample tag name1";
            List<Tag> tags = new List<Tag>(new Tag[] {tag});
            p.Tags = tags;
            p.Category = category;
            p.PhotoUrls = photoUrls;

            // add pet before testing
            PetApi petApi = new PetApi("http://petstore.swagger.io/v2/");
            petApi.AddPet (p);
        }
开发者ID:DariusMR,项目名称:swagger-codegen,代码行数:25,代码来源:TestPet.cs


示例2: TestEqual

        public void TestEqual()
        {
            // create pet
            Pet p1 = new Pet();
            p1.Id = petId;
            p1.Name = "Csharp test";
            p1.Status = "available";
            // create Category object
            Category category1 = new Category();
            category1.Id = 56;
            category1.Name = "sample category name2";
            List<String> photoUrls1 = new List<String>(new String[] {"sample photoUrls"});
            // create Tag object
            Tag tag1 = new Tag();
            tag1.Id = petId;
            tag1.Name = "sample tag name1";
            List<Tag> tags1 = new List<Tag>(new Tag[] {tag1});
            p1.Tags = tags1;
            p1.Category = category1;
            p1.PhotoUrls = photoUrls1;

            // create pet 2
            Pet p2 = new Pet();
            p2.Id = petId;
            p2.Name = "Csharp test";
            p2.Status = "available";
            // create Category object
            Category category2 = new Category();
            category2.Id = 56;
            category2.Name = "sample category name2";
            List<String> photoUrls2 = new List<String>(new String[] {"sample photoUrls"});
            // create Tag object
            Tag tag2 = new Tag();
            tag2.Id = petId;
            tag2.Name = "sample tag name1";
            List<Tag> tags2 = new List<Tag>(new Tag[] {tag2});
            p2.Tags = tags2;
            p2.Category = category2;
            p2.PhotoUrls = photoUrls2;

            // p1 and p2 should be equal (both object and attribute level)
            Assert.IsTrue (category1.Equals (category2));
            Assert.IsTrue (tags1.SequenceEqual (tags2));
            Assert.IsTrue (p1.PhotoUrls.SequenceEqual(p2.PhotoUrls));

            Assert.IsTrue (p1.Equals (p2));

            // update attribute to that p1 and p2 are not equal
            category2.Name = "new category name";
            Assert.IsFalse(category1.Equals (category2));

            tags2 = new List<Tag> ();
            Assert.IsFalse (tags1.SequenceEqual (tags2));

            // photoUrls has not changed so it should be equal
            Assert.IsTrue (p1.PhotoUrls.SequenceEqual(p2.PhotoUrls));

            Assert.IsFalse (p1.Equals (p2));
        }
开发者ID:praminda,项目名称:swagger-codegen,代码行数:59,代码来源:TestPet.cs


示例3: createPet

		/// <summary>
		/// Create a Pet object
		/// </summary>
		private Pet createPet()
		{
			// create pet
			Pet p = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
			p.Id = petId;
			//p.Name = "Csharp test";
			p.Status = Pet.StatusEnum.Available;
			// create Category object
			Category category = new Category();
			category.Id = 56;
			category.Name = "sample category name2";
			List<String> photoUrls = new List<String>(new String[] {"sample photoUrls"});
			// create Tag object
			Tag tag = new Tag();
			tag.Id = petId;
			tag.Name = "csharp sample tag name1";
			List<Tag> tags = new List<Tag>(new Tag[] {tag});
			p.Tags = tags;
			p.Category = category;
			p.PhotoUrls = photoUrls;

			return p;
		}
开发者ID:ckaeslin,项目名称:swagger-codegen,代码行数:26,代码来源:PetApiTests.cs


示例4: AddPetAsync

	 /// <summary>
    /// Add a new pet to the store 
    /// </summary>
    /// <param name="Body">Pet object that needs to be added to the store</param>
    /// <returns></returns>
    public async Task AddPetAsync (Pet Body) {

      

      var path = "/pet";
      path = path.Replace("{format}", "json");
      

      var queryParams = new Dictionary<String, String>();
      var headerParams = new Dictionary<String, String>();
      var formParams = new Dictionary<String, String>();
      var fileParams = new Dictionary<String, String>();
      String postBody = null;

      
      
      
      postBody = apiClient.Serialize(Body); // http body (model) parameter
      

      // authentication setting, if any
      String[] authSettings = new String[] { "petstore_auth" };

      // make the HTTP request
      IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
      if (((int)response.StatusCode) >= 400) {
        throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
      }
      
      return;
    }
开发者ID:Ernestet,项目名称:swagger-codegen,代码行数:36,代码来源:PetApi.cs


示例5: AddPetAsyncWithHttpInfo

        /// <summary>
        /// Add a new pet to the store 
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Pet object that needs to be added to the store</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task<ApiResponse<Object>> AddPetAsyncWithHttpInfo (Pet body)
        {
            // verify the required parameter 'body' is set
            if (body == null)
                throw new ApiException(400, "Missing required parameter 'body' when calling PetApi->AddPet");

            var localVarPath = "/pet";
            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", 
                "application/xml"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/xml", 
                "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 (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }

            // authentication (petstore_auth) required
            // oauth required
            if (!String.IsNullOrEmpty(Configuration.AccessToken))
            {
                localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
            }

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

            int localVarStatusCode = (int) localVarResponse.StatusCode;

            if (localVarStatusCode >= 400)
                throw new ApiException (localVarStatusCode, "Error calling AddPet: " + localVarResponse.Content, localVarResponse.Content);
            else if (localVarStatusCode == 0)
                throw new ApiException (localVarStatusCode, "Error calling AddPet: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);

            
            return new ApiResponse<Object>(localVarStatusCode,
                localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                null);
        }
开发者ID:Roustalski,项目名称:swagger-codegen,代码行数:72,代码来源:PetApi.cs


示例6: AddPetAsync

        /// <summary>
        /// Add a new pet to the store 
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Pet object that needs to be added to the store</param>
        /// <returns>Task of void</returns>
        public async System.Threading.Tasks.Task AddPetAsync (Pet body)
        {
             await AddPetAsyncWithHttpInfo(body);

        }
开发者ID:Roustalski,项目名称:swagger-codegen,代码行数:11,代码来源:PetApi.cs


示例7: AddPet

 /// <summary>
 /// Add a new pet to the store 
 /// </summary>
 /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="body">Pet object that needs to be added to the store</param>
 /// <returns></returns>
 public void AddPet (Pet body)
 {
      AddPetWithHttpInfo(body);
 }
开发者ID:Roustalski,项目名称:swagger-codegen,代码行数:10,代码来源:PetApi.cs


示例8: UpdatePet

 /// <summary>
 /// Update an existing pet 
 /// </summary>
 /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="body">Pet object that needs to be added to the store</param>
 /// <returns></returns>
 public void UpdatePet (Pet body)
 {
      UpdatePetWithHttpInfo(body);
 }
开发者ID:Roustalski,项目名称:swagger-codegen,代码行数:10,代码来源:PetApi.cs


示例9: AddPetAsyncWithHttpInfo

        /// <summary>
        /// Add a new pet to the store 
        /// </summary>
        /// <param name="body">Pet object that needs to be added to the store</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task<ApiResponse<Object>> AddPetAsyncWithHttpInfo (Pet body = null)
        {
            
    
            var path_ = "/pet";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            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", "application/xml"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/json", "application/xml"
            };
            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");
            
            
            
            
            postBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
            

            
            // authentication (petstore_auth) required
            
            // oauth required
            if (!String.IsNullOrEmpty(Configuration.AccessToken))
            {
                headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
            }
            

            // make the HTTP request
            IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, 
                Method.POST, queryParams, postBody, headerParams, formParams, fileParams, 
                pathParams, httpContentType);

            int statusCode = (int) response.StatusCode;
 
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling AddPet: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling AddPet: " + response.ErrorMessage, response.ErrorMessage);

            
            return new ApiResponse<Object>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                null);
        }
开发者ID:pkdevboxy,项目名称:swagger-codegen,代码行数:69,代码来源:PetApi.cs


示例10: UpdatePetAsync

        /// <summary>
        /// Update an existing pet 
        /// </summary>
        /// <param name="body">Pet object that needs to be added to the store</param>
        /// <returns>Task of void</returns>
        public async System.Threading.Tasks.Task UpdatePetAsync (Pet body = null)
        {
             await UpdatePetAsyncWithHttpInfo(body);

        }
开发者ID:pkdevboxy,项目名称:swagger-codegen,代码行数:10,代码来源:PetApi.cs


示例11: UpdatePet

     /// <summary>
     /// Update an existing pet 
     /// </summary>
     /// <param name="body">Pet object that needs to be added to the store</param> 
     /// <returns></returns>            
     public void UpdatePet (Pet body)
     {
         
 
         var path = "/pet";
         path = path.Replace("{format}", "json");
         
 
         var queryParams = new Dictionary<String, String>();
         var headerParams = new Dictionary<String, String>();
         var formParams = new Dictionary<String, String>();
         var fileParams = new Dictionary<String, FileParameter>();
         String postBody = null;
 
         
         
         
         postBody = ApiClient.Serialize(body); // http body (model) parameter
         
 
         // authentication setting, if any
         String[] authSettings = new String[] { "petstore_auth" };
 
         // make the HTTP request
         IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
 
         if (((int)response.StatusCode) >= 400)
             throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
         else if (((int)response.StatusCode) == 0)
             throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.ErrorMessage, response.ErrorMessage);
 
         return;
     }
开发者ID:achew22,项目名称:swagger-codegen,代码行数:38,代码来源:PetApi.cs


示例12: Init

 public void Init()
 {
     instance = new Pet();
 }
开发者ID:frantuma,项目名称:swagger-codegen,代码行数:4,代码来源:PetTests.cs


示例13: Init

 public void Init()
 {
     instance = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
 }
开发者ID:nbruno,项目名称:swagger-codegen,代码行数:4,代码来源:PetTests.cs


示例14: createPet

        /// <summary>
        /// Create a Pet object
        /// </summary>
        private Pet createPet()
        {
            // create pet
            Pet p = new Pet();
            p.Id = petId;
            p.Name = "Csharp test";
            p.Status = "available";
            // create Category object
            Category category = new Category();
            category.Id = 56;
            category.Name = "sample category name2";
            List<String> photoUrls = new List<String>(new String[] {"sample photoUrls"});
            // create Tag object
            Tag tag = new Tag();
            tag.Id = petId;
            tag.Name = "sample tag name1";
            List<Tag> tags = new List<Tag>(new Tag[] {tag});
            p.Tags = tags;
            p.Category = category;
            p.PhotoUrls = photoUrls;

            return p;
        }
开发者ID:mkrufky,项目名称:swagger-codegen,代码行数:26,代码来源:TestPet.cs


示例15: UpdatePetAsync

        /// <summary>
        /// Update an existing pet 
        /// </summary>
        /// <param name="body">Pet object that needs to be added to the store</param>
        /// <returns></returns>
        public async System.Threading.Tasks.Task UpdatePetAsync (Pet body)
        {
            
    
            var path = "/pet";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;
    
            pathParams.Add("format", "json");
            
            
            
            
            postBody = ApiClient.Serialize(body); // http body (model) parameter
            
    
            // authentication setting, if any
            String[] authSettings = new String[] { "petstore_auth" };
    
            // make the HTTP request
            IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
            if (((int)response.StatusCode) >= 400)
                throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);

            
            return;
        }
开发者ID:DariusMR,项目名称:swagger-codegen,代码行数:37,代码来源:PetApi.cs


示例16: AddPetAsync

        /// <summary>
        /// Add a new pet to the store 
        /// </summary>
        /// <param name="body">Pet object that needs to be added to the store</param>
        /// <returns></returns>
        public async System.Threading.Tasks.Task AddPetAsync (Pet body = null)
        {
            
    
            var path_ = "/pet";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

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

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            
            
            
            
            postBody = ApiClient.Serialize(body); // http body (model) parameter
            
    
            // authentication setting, if any
            String[] authSettings = new String[] { "petstore_auth" };
    
            // make the HTTP request
            IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
            if (((int)response.StatusCode) >= 400)
                throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);

            
            return;
        }
开发者ID:praminda,项目名称:swagger-codegen,代码行数:47,代码来源:PetApi.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Model.User类代码示例发布时间:2022-05-26
下一篇:
C# Client.ApiClient类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap