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

C# ClientModel.Method类代码示例

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

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



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

示例1: MethodTemplateModel

 /// <summary>
 /// Initializes a new instance of the class MethodTemplateModel.
 /// </summary>
 /// <param name="source">The source object.</param>
 /// <param name="serviceClient">The service client.</param>
 public MethodTemplateModel(Method source, ServiceClient serviceClient)
 {
     this.LoadFrom(source);
     ParameterTemplateModels = new List<ParameterTemplateModel>();
     source.Parameters.ForEach(p => ParameterTemplateModels.Add(new ParameterTemplateModel(p)));
     ServiceClient = serviceClient;
 }
开发者ID:xingwu1,项目名称:autorest,代码行数:12,代码来源:MethodTemplateModel.cs


示例2: OnBuildMethodParameter

        public static StringBuilder OnBuildMethodParameter(Method method,
            SwaggerParameter currentSwaggerParam,
            StringBuilder paramNameBuilder)
        {
            if (currentSwaggerParam == null)
            {
                throw new ArgumentNullException("currentSwaggerParam");
            }

            bool hasCollectionFormat = currentSwaggerParam.CollectionFormat != CollectionFormat.None;

            if (currentSwaggerParam.Type == DataType.Array && !hasCollectionFormat)
            {
                // If the parameter type is array default the collectionFormat to csv
                currentSwaggerParam.CollectionFormat = CollectionFormat.Csv;
            }

            if (hasCollectionFormat)
            {
                AddCollectionFormat(currentSwaggerParam, paramNameBuilder);
                if (currentSwaggerParam.In == ParameterLocation.Path)
                {
                    if (method == null || method.Url == null)
                    {
                       throw new ArgumentNullException("method"); 
                    }

                    method.Url = method.Url.Replace(
                        string.Format(CultureInfo.InvariantCulture, "{0}", currentSwaggerParam.Name),
                        string.Format(CultureInfo.InvariantCulture, "{0}", paramNameBuilder));
                }
            }
            return paramNameBuilder;
        }
开发者ID:maxkeller,项目名称:autorest,代码行数:34,代码来源:CollectionFormatBuilder.cs


示例3: MethodTemplateModel

 public MethodTemplateModel(Method source, ServiceClient serviceClient)
 {
     this.LoadFrom(source);
     ParameterTemplateModels = new List<ParameterTemplateModel>();
     source.Parameters.ForEach(p => ParameterTemplateModels.Add(new ParameterTemplateModel(p)));
     ServiceClient = serviceClient;
     if (source.Group != null)
     {
         OperationName = source.Group.ToPascalCase();
     }
     else
     {
         OperationName = serviceClient.Name;
     }
     AddCustomHeader = true;
     string formatter;
     foreach (var parameter in LocalParameters)
     {
         if (string.IsNullOrWhiteSpace(parameter.DefaultValue))
         {
             parameter.DefaultValue = PythonConstants.None;
         }
     }
     foreach (Match m in Regex.Matches(Url, @"\{[\w]+:[\w]+\}"))
     {
         formatter = m.Value.Split(':').First() + '}';
         Url = Url.Replace(m.Value, formatter);
     }
 }
开发者ID:xingwu1,项目名称:autorest,代码行数:29,代码来源:MethodTemplateModel.cs


示例4: MethodTemplateModel

 public MethodTemplateModel(Method source, ServiceClient serviceClient)
 {
     this.LoadFrom(source);
     ParameterTemplateModels = new List<ParameterTemplateModel>();
     LogicalParameterTemplateModels = new List<ParameterTemplateModel>();
     source.Parameters.ForEach(p => ParameterTemplateModels.Add(new ParameterTemplateModel(p)));
     source.LogicalParameters.ForEach(p => LogicalParameterTemplateModels.Add(new ParameterTemplateModel(p)));
     ServiceClient = serviceClient;
     MethodGroupName = source.Group ?? serviceClient.Name;
 }
开发者ID:DebugOfTheRoad,项目名称:autorest,代码行数:10,代码来源:MethodTemplateModel.cs


示例5: AzureMethodTemplateModel

        /// <summary>
        /// Initializes a new instance of the AzureMethodTemplateModel class.
        /// </summary>
        /// <param name="source">The method current model is built for.</param>
        /// <param name="serviceClient">The service client - main point of access to the SDK.</param>
        public AzureMethodTemplateModel(Method source, ServiceClient serviceClient)
            : base(source, serviceClient)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            ParameterTemplateModels.Clear();
            source.Parameters.ForEach(p => ParameterTemplateModels.Add(new AzureParameterTemplateModel(p)));
        }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:16,代码来源:AzureMethodTemplateModel.cs


示例6: AzureMethodTemplateModel

 public AzureMethodTemplateModel(Method source, ServiceClient serviceClient)
     : base(source, serviceClient)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     
     this.ClientRequestIdString = AzureExtensions.GetClientRequestIdString(source);
     this.RequestIdString = AzureExtensions.GetRequestIdString(source);
 }
开发者ID:DebugOfTheRoad,项目名称:autorest,代码行数:11,代码来源:AzureMethodTemplateModel.cs


示例7: MethodTemplateModel

 public MethodTemplateModel(Method source, ServiceClient serviceClient)
 {
     this.LoadFrom(source);
     ParameterTemplateModels = new List<ParameterTemplateModel>();
     LogicalParameterTemplateModels = new List<ParameterTemplateModel>();
     source.Parameters.ForEach(p => ParameterTemplateModels.Add(new ParameterTemplateModel(p)));
     source.LogicalParameters.ForEach(p => LogicalParameterTemplateModels.Add(new ParameterTemplateModel(p)));
     ServiceClient = serviceClient;
     MethodGroupName = source.Group ?? serviceClient.Name;
     this.IsCustomBaseUri = serviceClient.Extensions.ContainsKey(Microsoft.Rest.Generator.Extensions.ParameterizedHostExtension);
 }
开发者ID:jkonecki,项目名称:autorest,代码行数:11,代码来源:MethodTemplateModel.cs


示例8: AzureMethodTemplateModel

        /// <summary>
        /// Initializes a new instance of the AzureMethodTemplateModel class.
        /// </summary>
        /// <param name="source">The method current model is built for.</param>
        /// <param name="serviceClient">The service client - main point of access to the SDK.</param>
        public AzureMethodTemplateModel(Method source, ServiceClient serviceClient)
            : base(source, serviceClient)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            ParameterTemplateModels.Clear();
            source.Parameters.ForEach(p => ParameterTemplateModels.Add(new AzureParameterTemplateModel(p)));

            this.ClientRequestIdString = AzureExtensions.GetClientRequestIdString(source);
            this.RequestIdString = AzureExtensions.GetRequestIdString(source);
        }
开发者ID:maxkeller,项目名称:autorest,代码行数:19,代码来源:AzureMethodTemplateModel.cs


示例9: AzureMethodTemplateModel

        public AzureMethodTemplateModel(Method source, ServiceClient serviceClient)
            : base(source, serviceClient)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.ClientRequestIdString = AzureExtensions.GetClientRequestIdString(source);
            this.RequestIdString = AzureExtensions.GetRequestIdString(source);
            _returnTypeModel = new AzureResponseModel(ReturnType, this);
            _responseModels = new Dictionary<HttpStatusCode, ResponseModel>();
            Responses.ForEach(r => _responseModels.Add(r.Key, new AzureResponseModel(r.Value, this)));
        }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:14,代码来源:AzureMethodTemplateModel.cs


示例10: MethodTemplateModel

 public MethodTemplateModel(Method source, ServiceClient serviceClient)
 {
     this.LoadFrom(source);
     ParameterTemplateModels = new List<ParameterTemplateModel>();
     source.Parameters.ForEach(p => ParameterTemplateModels.Add(new ParameterTemplateModel(p)));
     ServiceClient = serviceClient;
     if (source.Group != null)
     {
         OperationName = source.Group.ToPascalCase();
     }
     else
     {
         OperationName = serviceClient.Name;
     }
 }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:15,代码来源:MethodTemplateModel.cs


示例11: ParameterModel

 public ParameterModel(Parameter parameter, Method method)
     : base()
 {
     this.LoadFrom(parameter);
     this._method = method;
     // Use instance type for optional parameters
     if (!this.IsRequired)
     {
         this.Type = ((ITypeModel) Type).InstanceType();
     }
     _wireName = this.Name.ToCamelCase();
     if (NeedsConversion)
     {
         _wireName += "Converted";
     }
     _implImports = new List<string>();
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:17,代码来源:ParameterModel.cs


示例12: MethodTemplateModel

 public MethodTemplateModel(Method source, ServiceClient serviceClient)
 {
     this.LoadFrom(source);
     ParameterTemplateModels = new List<ParameterTemplateModel>();
     source.Parameters.Where(p => p.Location == ParameterLocation.Path).ForEach(p => ParameterTemplateModels.Add(new ParameterTemplateModel(p)));
     source.Parameters.Where(p => p.Location != ParameterLocation.Path).ForEach(p => ParameterTemplateModels.Add(new ParameterTemplateModel(p)));
     ServiceClient = serviceClient;
     if (source.Group != null)
     {
         OperationName = source.Group.ToPascalCase();
         ClientReference = "client";
     }
     else
     {
         OperationName = serviceClient.Name;
         ClientReference = "";
     }
 }
开发者ID:JamesTryand,项目名称:autorest,代码行数:18,代码来源:MethodTemplateModel.cs


示例13: AzureMethodTemplateModel

        public AzureMethodTemplateModel(Method source, ServiceClient serviceClient, SyncMethodsGenerationMode syncWrappers)
            : base(source, serviceClient, syncWrappers)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            ParameterTemplateModels.Clear();
            LogicalParameterTemplateModels.Clear();
            source.Parameters.ForEach(p => ParameterTemplateModels.Add(new AzureParameterTemplateModel(p)));
            source.LogicalParameters.ForEach(p => LogicalParameterTemplateModels.Add(new AzureParameterTemplateModel(p)));
            if (MethodGroupName != ServiceClient.Name)
            {
                MethodGroupName = MethodGroupName + "Operations";
            }

            this.ClientRequestIdString = AzureExtensions.GetClientRequestIdString(source);
            this.RequestIdString = AzureExtensions.GetRequestIdString(source);
        }
开发者ID:xingwu1,项目名称:autorest,代码行数:20,代码来源:AzureMethodTemplateModel.cs


示例14: AzureMethodTemplateModel

        public AzureMethodTemplateModel(Method source, ServiceClient serviceClient)
            : base(source, serviceClient)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            this.ClientRequestIdString = AzureExtensions.GetClientRequestIdString(source);
            this.RequestIdString = AzureExtensions.GetRequestIdString(source);
            _returnTypeModel = new AzureResponseModel(ReturnType, this);
            _responseModels = new Dictionary<HttpStatusCode, ResponseModel>();
            Responses.ForEach(r => _responseModels.Add(r.Key, new AzureResponseModel(r.Value, this)));

            if (this.IsPagingOperation || this.IsPagingNextOperation)
            {
                var ext = this.Extensions[AzureExtensions.PageableExtension] as Newtonsoft.Json.Linq.JContainer;
                pageClassName = (string)ext["className"] ?? "PageImpl";
            }
        }
开发者ID:xingwu1,项目名称:autorest,代码行数:20,代码来源:AzureMethodTemplateModel.cs


示例15: MethodTemplateModel

 public MethodTemplateModel(Method source, ServiceClient serviceClient)
 {
     this.LoadFrom(source);
     ParameterModels = new List<ParameterModel>();
     LogicalParameterModels = new List<ParameterModel>();
     source.Parameters.Where(p => p.Location == ParameterLocation.Path).ForEach(p => ParameterModels.Add(new ParameterModel(p, this)));
     source.Parameters.Where(p => p.Location != ParameterLocation.Path).ForEach(p => ParameterModels.Add(new ParameterModel(p, this)));
     source.LogicalParameters.ForEach(p => LogicalParameterModels.Add(new ParameterModel(p, this)));
     ServiceClient = serviceClient;
     if (source.Group != null)
     {
         OperationName = source.Group.ToPascalCase();
         ClientReference = "this.client";
     }
     else
     {
         OperationName = serviceClient.Name;
         ClientReference = "this";
     }
     _returnTypeModel = new ResponseModel(ReturnType);
     _responseModels = new Dictionary<HttpStatusCode,ResponseModel>();
     Responses.ForEach(r => _responseModels.Add(r.Key, new ResponseModel(r.Value)));
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:23,代码来源:MethodTemplateModel.cs


示例16: DefaultValue

 public string DefaultValue(Method method)
 {
     if (this.Name == "byte[]")
     {
         return "new byte[0]";
     }
     else if (this.Name == "Byte[]")
     {
         return "new Byte[0]";
     }
     else if (this.Name == "RequestBody")
     {
         return "RequestBody.create(MediaType.parse(\"" + method.RequestContentType + "\"), new byte[0])";
     }
     else if (this.IsInstanceType)
     // instance type
     {
         return "null";
     }
     else
     {
         throw new NotSupportedException(this.Name + " does not have default value!");
     }
 }
开发者ID:jkonecki,项目名称:autorest,代码行数:24,代码来源:PrimaryTypeModel.cs


示例17: Clone

 /// <summary>
 /// Performs a deep clone of a method.
 /// </summary>
 /// <returns></returns>
 public object Clone()
 {
     Method newMethod = new Method();
     newMethod.LoadFrom(this);
     newMethod.Extensions = new Dictionary<string, object>();
     newMethod.Parameters = new List<Parameter>();
     newMethod.RequestHeaders = new Dictionary<string, string>();
     newMethod.Responses = new Dictionary<HttpStatusCode, Response>();
     newMethod.InputParameterTransformation = new List<ParameterTransformation>();
     newMethod.Scope = new ScopeProvider();
     this.Extensions.ForEach(e => newMethod.Extensions[e.Key] = e.Value);
     this.Parameters.ForEach(p => newMethod.Parameters.Add((Parameter)p.Clone()));
     this.InputParameterTransformation.ForEach(m => newMethod.InputParameterTransformation.Add((ParameterTransformation)m.Clone()));
     this.RequestHeaders.ForEach(r => newMethod.RequestHeaders[r.Key] = r.Value);
     this.Responses.ForEach(r => newMethod.Responses[r.Key] = r.Value);
     return newMethod;
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:21,代码来源:Method.cs


示例18: ResourceIsFlattenedForConflictingResource

        public void ResourceIsFlattenedForConflictingResource()
        {
            var serviceClient = new ServiceClient();
            serviceClient.BaseUrl = "https://petstore.swagger.wordnik.com";
            serviceClient.ApiVersion = "1.0.0";
            serviceClient.Documentation =
                "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification";
            serviceClient.Name = "Swagger Petstore";

            var getPet = new Method();
            var resource = new CompositeType();
            var dogProperties = new CompositeType();
            var dog = new CompositeType();
            serviceClient.Methods.Add(getPet);
            resource.Name = "resource";
            resource.Extensions[AzureExtensions.AzureResourceExtension] = true;
            resource.Properties.Add(new Property
            {
                Name = "id",
                Type = PrimaryType.String,
                IsRequired = true
            });
            resource.Properties.Add(new Property
            {
                Name = "location",
                Type = PrimaryType.String,
                IsRequired = true
            });
            resource.Properties.Add(new Property
            {
                Name = "name",
                Type = PrimaryType.String,
                IsRequired = true
            });
            resource.Properties.Add(new Property
            {
                Name = "tags",
                Type = new SequenceType { ElementType = PrimaryType.String },
                IsRequired = true
            });
            resource.Properties.Add(new Property
            {
                Name = "type",
                Type = PrimaryType.String,
                IsRequired = true
            });
            dogProperties.Name = "dogProperties";
            dogProperties.Properties.Add(new Property
            {
                Name = "id",
                Type = PrimaryType.Long,
                IsRequired = true
            });
            dogProperties.Properties.Add(new Property
            {
                Name = "name",
                Type = PrimaryType.String,
                IsRequired = true
            });
            dog.Name = "dog";
            dog.BaseModelType = resource;
            dog.Properties.Add(new Property
            {
                Name = "properties",
                Type = dogProperties,
                IsRequired = true
            });
            dog.Properties.Add(new Property
            {
                Name = "pedigree",
                Type = PrimaryType.Boolean,
                IsRequired = true
            });
            getPet.ReturnType = new Response(dog, null);

            serviceClient.ModelTypes.Add(resource);
            serviceClient.ModelTypes.Add(dogProperties);
            serviceClient.ModelTypes.Add(dog);

            var codeGen = new SampleAzureCodeGenerator(new Settings());
            codeGen.NormalizeClientModel(serviceClient);
            Assert.Equal(3, serviceClient.ModelTypes.Count);
            Assert.Equal("dog", serviceClient.ModelTypes.First(m => m.Name == "dog").Name);
            Assert.Equal(3, serviceClient.ModelTypes.First(m => m.Name == "dog").Properties.Count);
            Assert.True(serviceClient.ModelTypes.First(m => m.Name == "dog").Properties.Any(p => p.Name == "dogName"));
            Assert.True(serviceClient.ModelTypes.First(m => m.Name == "dog").Properties.Any(p => p.Name == "dogId"));
            Assert.True(serviceClient.ModelTypes.First(m => m.Name == "dog").Properties.Any(p => p.Name == "pedigree"));
            Assert.Equal("dog", serviceClient.Methods[0].ReturnType.Body.Name);
            Assert.Equal(serviceClient.ModelTypes.First(m => m.Name == "dog"), serviceClient.Methods[0].ReturnType.Body);
        }
开发者ID:maxkeller,项目名称:autorest,代码行数:90,代码来源:AzureServiceClientNormalizerTests.cs


示例19: BuildMethod

        public Method BuildMethod(HttpMethod httpMethod, string url, string methodName, string methodGroup)
        {
            EnsureUniqueMethodName(methodName, methodGroup);

            var method = new Method
            {
                HttpMethod = httpMethod,
                Url = url,
                Name = methodName,
                SerializedName = _operation.OperationId
            };

            method.RequestContentType = _effectiveConsumes.FirstOrDefault() ?? APP_JSON_MIME;
            string produce = _effectiveConsumes.FirstOrDefault(s => s.StartsWith(APP_JSON_MIME, StringComparison.OrdinalIgnoreCase));
            if (!string.IsNullOrEmpty(produce))
            {
                method.RequestContentType = produce;
            }

            if (method.RequestContentType.StartsWith(APP_JSON_MIME, StringComparison.OrdinalIgnoreCase) &&
                method.RequestContentType.IndexOf("charset=", StringComparison.OrdinalIgnoreCase) == -1)
            {
                // Enable UTF-8 charset
                method.RequestContentType += "; charset=utf-8";
            }
            method.Description = _operation.Description;
            method.Summary = _operation.Summary;

            // Service parameters
            if (_operation.Parameters != null)
            {
                foreach (var swaggerParameter in DeduplicateParameters(_operation.Parameters))
                {
                    var parameter = ((ParameterBuilder) swaggerParameter.GetBuilder(_swaggerModeler)).Build();
                    method.Parameters.Add(parameter);

                    StringBuilder parameterName = new StringBuilder(parameter.Name);
                    parameterName = CollectionFormatBuilder.OnBuildMethodParameter(method, swaggerParameter,
                        parameterName);

                    if (swaggerParameter.In == ParameterLocation.Header)
                    {
                        method.RequestHeaders[swaggerParameter.Name] =
                            string.Format(CultureInfo.InvariantCulture, "{{{0}}}", parameterName);
                    }
                }
            }

            // Build header object
            var responseHeaders = new Dictionary<string, Header>();
            foreach (var response in _operation.Responses.Values)
            {
                if (response.Headers != null)
                {
                    response.Headers.ForEach( h => responseHeaders[h.Key] = h.Value);
                }
            }

            var headerTypeName = string.Format(CultureInfo.InvariantCulture,
                "{0}-{1}-Headers", methodGroup, methodName).Trim('-');
            var headerType = new CompositeType
            {
                Name = headerTypeName,
                SerializedName = headerTypeName,
                Documentation = string.Format(CultureInfo.InvariantCulture, "Defines headers for {0} operation.", methodName)
            };
            responseHeaders.ForEach(h =>
            {
                var property = new Property
                {
                    Name = h.Key,
                    SerializedName = h.Key,
                    Type = h.Value.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key),
                    Documentation = h.Value.Description
                };
                headerType.Properties.Add(property);
            });

            if (!headerType.Properties.Any())
            {
                headerType = null;
            }

            // Response format
            var typesList = new List<Stack<IType>>();
            foreach (var response in _operation.Responses)
            {
                if (string.Equals(response.Key, "default", StringComparison.OrdinalIgnoreCase))
                {
                    TryBuildDefaultResponse(methodName, response.Value, method, headerType);
                }
                else
                {
                    if (
                        !(TryBuildResponse(methodName, response.Key.ToHttpStatusCode(), response.Value, method,
                            typesList, headerType) ||
                          TryBuildStreamResponse(response.Key.ToHttpStatusCode(), response.Value, method, typesList, headerType) ||
                          TryBuildEmptyResponse(methodName, response.Key.ToHttpStatusCode(), response.Value, method,
                              typesList, headerType)))
                    {
//.........这里部分代码省略.........
开发者ID:Ranjana1996,项目名称:autorest,代码行数:101,代码来源:OperationBuilder.cs


示例20: TryBuildDefaultResponse

 private void TryBuildDefaultResponse(string methodName, OperationResponse response, Method method, IType headerType)
 {
     IType errorModel = null;
     if (SwaggerOperationProducesJson())
     {
         if (TryBuildResponseBody(methodName, response, s => GenerateErrorModelName(s), out errorModel))
         {
             method.DefaultResponse = new Response(errorModel, headerType);
         }
     }
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:11,代码来源:OperationBuilder.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ClientModel.ServiceClient类代码示例发布时间:2022-05-26
下一篇:
C# ClientModel.CompositeType类代码示例发布时间: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