本文整理汇总了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)));
}
示例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;
}
示例3: ParseWithEmptyServiceClient
public void ParseWithEmptyServiceClient()
{
ServiceClient serviceClient = new ServiceClient();
IDictionary<string, ResourceSchema> schemas = ResourceSchemaParser.Parse(serviceClient);
Assert.NotNull(schemas);
Assert.Equal(0, schemas.Count);
}
示例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"));
}
示例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");
}
示例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");
}
示例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");
}
}
示例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)));
}
示例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;
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
}
}
}
示例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");
}
示例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);
}