本文整理汇总了C#中Microsoft.Rest.Generator.ClientModel.ServiceClient类的典型用法代码示例。如果您正苦于以下问题:C# ServiceClient类的具体用法?C# ServiceClient怎么用?C# ServiceClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceClient类属于Microsoft.Rest.Generator.ClientModel命名空间,在下文中一共展示了ServiceClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: NormalizeClientModelDoesNothing
public void NormalizeClientModelDoesNothing()
{
ServiceClient serviceClient = new ServiceClient();
CreateGenerator().NormalizeClientModel(serviceClient);
// Nothing happens
}
开发者ID:tdjastrzebski,项目名称:autorest,代码行数:7,代码来源:AzureResourceSchemaCodeGeneratorTests.cs
示例17: AzureMethodGroupTemplateModel
public AzureMethodGroupTemplateModel(ServiceClient serviceClient, string methodGroupName)
: base(serviceClient, methodGroupName)
{
MethodTemplateModels.Clear();
Methods.Where(m => m.Group == MethodGroupName)
.ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient)));
}
开发者ID:Ranjana1996,项目名称:autorest,代码行数:7,代码来源:AzureMethodGroupTemplateModel.cs
示例18: 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;
// This extension from general extensions must be run prior to Azure specific extensions.
ProcessParameterizedHost(serviceClient, settings);
UpdateHeadMethods(serviceClient);
ParseODataExtension(serviceClient);
FlattenModels(serviceClient);
FlattenMethodParameters(serviceClient, settings);
AddParameterGroups(serviceClient);
AddLongRunningOperations(serviceClient);
AddAzureProperties(serviceClient);
SetDefaultResponses(serviceClient);
AddPageableMethod(serviceClient, codeNamer);
}
开发者ID:Ranjana1996,项目名称:autorest,代码行数:37,代码来源:AzureExtensions.cs
示例19: 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
示例20: NormalizeClientModel
/// <summary>
/// Recursively normalizes names in the client model
/// </summary>
/// <param name="client"></param>
public virtual void NormalizeClientModel(ServiceClient client)
{
if (client == null)
{
throw new ArgumentNullException("client");
}
client.Name = GetTypeName(client.Name);
client.Namespace = GetNamespaceName(client.Namespace);
foreach (var property in client.Properties)
{
property.Name = GetPropertyName(property.Name);
property.Type = NormalizeType(property.Type);
}
var normalizedModels = new List<CompositeType>();
foreach (var modelType in client.ModelTypes)
{
normalizedModels.Add(NormalizeType(modelType) as CompositeType);
}
client.ModelTypes.Clear();
normalizedModels.ForEach( (item) => client.ModelTypes.Add(item));
var normalizedEnums = new List<EnumType>();
foreach (var enumType in client.EnumTypes)
{
var normalizedType = NormalizeType(enumType) as EnumType;
if (normalizedType != null)
{
normalizedEnums.Add(NormalizeType(enumType) as EnumType);
}
}
client.EnumTypes.Clear();
normalizedEnums.ForEach((item) => client.EnumTypes.Add(item));
foreach (var method in client.Methods)
{
method.Name = GetMethodName(method.Name);
method.Group = GetTypeName(method.Group);
method.ReturnType = NormalizeType(method.ReturnType);
method.DefaultResponse = NormalizeType(method.DefaultResponse);
var normalizedResponses = new Dictionary<HttpStatusCode, IType>();
foreach (var statusCode in method.Responses.Keys)
{
normalizedResponses[statusCode] = NormalizeType(method.Responses[statusCode]);
}
method.Responses.Clear();
foreach (var statusCode in normalizedResponses.Keys)
{
method.Responses[statusCode] = normalizedResponses[statusCode];
}
foreach (var parameter in method.Parameters)
{
parameter.Name = GetParameterName(parameter.Name);
parameter.Type = NormalizeType(parameter.Type);
}
}
}
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:63,代码来源:CodeNamer.cs
注:本文中的Microsoft.Rest.Generator.ClientModel.ServiceClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论