當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。