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


C# ClientModel.ServiceClient类代码示例

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


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

示例1: ServiceClientTemplateModel

 public ServiceClientTemplateModel(ServiceClient serviceClient)
 {
     this.LoadFrom(serviceClient);
     MethodTemplateModels = new List<MethodTemplateModel>();
     Methods.Where(m => m.Group == null)
         .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, serviceClient)));
 }
开发者ID:juvchan,项目名称:autorest,代码行数:7,代码来源:ServiceClientTemplateModel.cs

示例2: ProcessParameterizedHost

        public static void ProcessParameterizedHost(ServiceClient serviceClient, Settings settings)
        {
            if (serviceClient == null)
            {
                throw new ArgumentNullException("serviceClient");
            }

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (serviceClient.Extensions.ContainsKey(ParameterizedHostExtension) && !hostChecked)
            { 
                SwaggerModeler modeler = new SwaggerModeler(settings);
                modeler.Build();
                var hostExtension = serviceClient.Extensions[ParameterizedHostExtension] as JObject;

                if (hostExtension != null)
                {
                    var hostTemplate = (string)hostExtension["hostTemplate"];
                    var parametersJson = hostExtension["parameters"].ToString();
                    if (!string.IsNullOrEmpty(parametersJson))
                    {
                        var jsonSettings = new JsonSerializerSettings
                        {
                            TypeNameHandling = TypeNameHandling.None,
                            MetadataPropertyHandling = MetadataPropertyHandling.Ignore
                        };

                        var swaggerParams = JsonConvert.DeserializeObject<List<SwaggerParameter>>(parametersJson, jsonSettings);
                        
                        foreach (var swaggerParameter in swaggerParams)
                        {
                            // Build parameter
                            var parameterBuilder = new ParameterBuilder(swaggerParameter, modeler);
                            var parameter = parameterBuilder.Build();

                            // check to see if the parameter exists in properties, and needs to have its name normalized
                            if (serviceClient.Properties.Any(p => p.SerializedName.Equals(parameter.SerializedName)))
                            {
                                parameter.ClientProperty = serviceClient.Properties.Single(p => p.SerializedName.Equals(parameter.SerializedName));
                            }
                            parameter.Extensions["hostParameter"] = true;

                            foreach (var method in serviceClient.Methods)
                            {
                                method.Parameters.Add(parameter);
                            }
                        }

                        serviceClient.BaseUrl = string.Format(CultureInfo.InvariantCulture, "{0}://{1}{2}",
                        modeler.ServiceDefinition.Schemes[0].ToString().ToLowerInvariant(),
                        hostTemplate, modeler.ServiceDefinition.BasePath);
                    }
                }
            }

            hostChecked = true;
        }
开发者ID:jkonecki,项目名称:autorest,代码行数:60,代码来源:Extensions.cs

示例3: ParseWithEmptyServiceClient

 public void ParseWithEmptyServiceClient()
 {
     ServiceClient serviceClient = new ServiceClient();
     IDictionary<string, ResourceSchema> schemas = ResourceSchemaParser.Parse(serviceClient);
     Assert.NotNull(schemas);
     Assert.Equal(0, schemas.Count);
 }
开发者ID:xingwu1,项目名称:autorest,代码行数:7,代码来源:ResourceSchemaParserTests.cs

示例4: Generate

 public override async Task Generate(ServiceClient serviceClient)
 {
     var viewModel = new SampleViewModel();
     var model = new SampleModel();
     model.Model = viewModel;
     await Write(model, Path.Combine("Models", "Pet.cs"));
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:7,代码来源:SampleCodeGenerator.cs

示例5: Generate

 public override async Task Generate(ServiceClient serviceClient)
 {
     var viewModel = new SampleViewModel();
     var model = new SampleModel();
     model.Model = viewModel;
     await Write(model, "Models\\Pet.cs");
 }
开发者ID:juvchan,项目名称:autorest,代码行数:7,代码来源:SampleCodeGenerator.cs

示例6: NormalizeClientModel

 /// <summary>
 /// Normalizes client model by updating names and types to be language specific.
 /// </summary>
 /// <param name="serviceClient"></param>
 public override void NormalizeClientModel(ServiceClient serviceClient)
 {
     PopulateAdditionalProperties(serviceClient);
     _namer.NormalizeClientModel(serviceClient);
     _namer.ResolveNameCollisions(serviceClient, Settings.Namespace,
         Settings.Namespace + ".Models");
 }
开发者ID:juvchan,项目名称:autorest,代码行数:11,代码来源:CSharpCodeGenerator.cs

示例7: NormalizePaginatedMethods

 /// <summary>
 /// Changes paginated method signatures to return Page type.
 /// </summary>
 /// <param name="serviceClient"></param>
 public virtual void NormalizePaginatedMethods(ServiceClient serviceClient)
 {
     if (serviceClient == null)
     {
         throw new ArgumentNullException("serviceClient");
     }
 }
开发者ID:BretJohnson,项目名称:autorest,代码行数:11,代码来源:AzureJavaCodeNamer.cs

示例8: AzureServiceClientTemplateModel

 /// <summary>
 /// Initializes a new instance of the AzureServiceClientTemplateModel class.
 /// </summary>
 /// <param name="serviceClient">The service client instance.</param>
 public AzureServiceClientTemplateModel(ServiceClient serviceClient)
     : base(serviceClient)
 {
     MethodTemplateModels.Clear();
     Methods.Where(m => m.Group == null)
         .ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient)));
 }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:11,代码来源:AzureServiceClientTemplateModel.cs

示例9: 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

示例10: NormalizeAzureClientModel

        /// <summary>
        /// Normalizes client model using Azure-specific extensions.
        /// </summary>
        /// <param name="serviceClient">Service client</param>
        /// <param name="settings">AutoRest settings</param>
        /// <param name="codeNamer">AutoRest settings</param>
        /// <returns></returns>
        public static void NormalizeAzureClientModel(ServiceClient serviceClient, Settings settings, CodeNamer codeNamer)
        {
            if (serviceClient == null)
            {
                throw new ArgumentNullException("serviceClient");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (codeNamer == null)
            {
                throw new ArgumentNullException("codeNamer");
            }

            settings.AddCredentials = true;
            UpdateHeadMethods(serviceClient);
            ParseODataExtension(serviceClient);
            FlattenResourceProperties(serviceClient);
            FlattenRequestPayload(serviceClient, settings);
            AddLongRunningOperations(serviceClient);
            AddAzureProperties(serviceClient);
            SetDefaultResponses(serviceClient);
            AddParameterGroups(serviceClient);
            AddPageableMethod(serviceClient, codeNamer);
        }
开发者ID:maxkeller,项目名称:autorest,代码行数:33,代码来源:AzureExtensions.cs

示例11: NormalizeClientModel

 /// <summary>
 /// Normalizes client model using generic extensions.
 /// </summary>
 /// <param name="serviceClient">Service client</param>
 /// <param name="settings">AutoRest settings</param>
 /// <returns></returns>
 public static void NormalizeClientModel(ServiceClient serviceClient, Settings settings)
 {
     FlattenModels(serviceClient);
     FlattenMethodParameters(serviceClient, settings);
     ParameterGroupExtensionHelper.AddParameterGroups(serviceClient);
     ProcessParameterizedHost(serviceClient, settings);
 }
开发者ID:xingwu1,项目名称:autorest,代码行数:13,代码来源:Extensions.cs

示例12: NormalizeClientModel

 /// <summary>
 /// Normalizes client model by updating names and types to be language specific.
 /// </summary>
 /// <param name="serviceClient"></param>
 public override void NormalizeClientModel(ServiceClient serviceClient)
 {
     base.NormalizeClientModel(serviceClient);
     _namer.NormalizeClientModel(serviceClient);
     _namer.ResolveNameCollisions(serviceClient, Settings.Namespace,
         Settings.Namespace + ".Models");
 }
开发者ID:juvchan,项目名称:autorest,代码行数:11,代码来源:AzureCSharpCodeGenerator.cs

示例13: NormalizeClientModel

        public override void NormalizeClientModel(ServiceClient client)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            base.NormalizeClientModel(client);
            foreach (var method in client.Methods)
            {
                var scope = new ScopeProvider();
                foreach (var parameter in method.Parameters)
                {
                    if (parameter.ClientProperty != null)
                    {
                        parameter.Name = string.Format(CultureInfo.InvariantCulture,
                            "{0}.{1}", 
                            method.Group == null ? "this" : "this.Client", 
                            parameter.ClientProperty.Name);
                    }
                    else
                    {
                        parameter.Name = scope.GetVariableName(parameter.Name);   
                    }
                }
            }
        }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:27,代码来源:CSharpCodeNamer.cs

示例14: NormalizeClientModel

 /// <summary>
 /// Normalizes client model by updating names and types to be language specific.
 /// </summary>
 /// <param name="serviceClientModel"></param>
 public override void NormalizeClientModel(ServiceClient serviceClientModel)
 {
     PopulateAdditionalProperties(serviceClientModel);
     namingFramework.NormalizeClientModel(serviceClientModel);
     namingFramework.ResolveNameCollisions(serviceClientModel, Settings.Namespace,
         Settings.Namespace + "::Models");
 }
开发者ID:juvchan,项目名称:autorest,代码行数:11,代码来源:RubyCodeGenerator.cs

示例15: TestGenerate

        private static async Task TestGenerate(string apiVersion, string[] methodUrls, string expectedJsonString)
        {
            MemoryFileSystem fileSystem = new MemoryFileSystem();

            Settings settings = new Settings();
            settings.FileSystem = fileSystem;

            ServiceClient serviceClient = new ServiceClient();
            serviceClient.ApiVersion = apiVersion;
            foreach(string methodUrl in methodUrls)
            {
                serviceClient.Methods.Add(new Method()
                {
                    Url = methodUrl,
                    HttpMethod = HttpMethod.Put,
                });
            }
            await CreateGenerator(settings).Generate(serviceClient);

            Assert.Equal(2, fileSystem.VirtualStore.Count);

            string folderPath = fileSystem.VirtualStore.Keys.First();
            Assert.Equal("Folder", fileSystem.VirtualStore[folderPath].ToString());

            JObject expectedJSON = JObject.Parse(expectedJsonString);

            string fileContents = fileSystem.VirtualStore[fileSystem.VirtualStore.Keys.Skip(1).First()].ToString();
            JObject actualJson = JObject.Parse(fileContents);

            Assert.Equal(expectedJSON, actualJson);
        }
开发者ID:tdjastrzebski,项目名称:autorest,代码行数:31,代码来源:AzureResourceSchemaCodeGeneratorTests.cs


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