本文整理汇总了C#中AutoRest.Core.ClientModel.ServiceClient类的典型用法代码示例。如果您正苦于以下问题:C# ServiceClient类的具体用法?C# ServiceClient怎么用?C# ServiceClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceClient类属于AutoRest.Core.ClientModel命名空间,在下文中一共展示了ServiceClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequirementsTemplateModel
/// <summary>
/// Initializes a new instance of RequirementsTemplateModel class.
/// </summary>
/// <param name="serviceClient">The service client.</param>
/// <param name="sdkName">The name of the SDK.</param>
/// <param name="implementationFileExtension">The files extension.</param>
/// <param name="ns">The namespace of the SDK.</param>
public RequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string implementationFileExtension, string ns)
{
this.LoadFrom(serviceClient);
this.ns = ns;
this.sdkName = sdkName;
this.implementationFileExtension = implementationFileExtension;
}
示例2: AzureFluentModelTemplateModel
public AzureFluentModelTemplateModel(CompositeType source, ServiceClient serviceClient)
: base(source, serviceClient)
{
_namer = new AzureJavaFluentCodeNamer(serviceClient.Namespace);
PropertyModels = new List<PropertyModel>();
Properties.ForEach(p => PropertyModels.Add(new FluentPropertyModel(p, serviceClient.Namespace, IsInnerModel)));
}
示例3: 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)));
}
示例4: 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);
}
示例5: NormalizeClientModelDoesNothing
public void NormalizeClientModelDoesNothing()
{
ServiceClient serviceClient = new ServiceClient();
CreateGenerator().NormalizeClientModel(serviceClient);
// Nothing happens
}
示例6: 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)));
}
示例7: AzureMethodGroupTemplateModel
public AzureMethodGroupTemplateModel(ServiceClient serviceClient, string methodGroupName)
: base(serviceClient, methodGroupName)
{
// Clear base initialized MethodTemplateModels and re-populate with
// AzureMethodTemplateModel
MethodTemplateModels.Clear();
var currentMethods = Methods.Where(m => m.Group == MethodGroupName && m.Extensions.ContainsKey(AzureExtensions.PageableExtension));
var nextListMethods = new List<Method>();
foreach (var method in currentMethods)
{
var pageableExtension = method.Extensions[AzureExtensions.PageableExtension] as Newtonsoft.Json.Linq.JContainer;
var operationName = (string)pageableExtension["operationName"];
if (operationName != null)
{
var nextLinkMethod = Methods.FirstOrDefault(m =>
operationName.Equals(m.SerializedName, StringComparison.OrdinalIgnoreCase));
if (nextLinkMethod != null)
{
method.Extensions["nextLinkURL"] = nextLinkMethod.Url;
method.Extensions["nextLinkParameters"] = nextLinkMethod.LogicalParameters;
nextListMethods.Add(nextLinkMethod);
}
}
}
Methods.RemoveAll(m => nextListMethods.Contains(m));
Methods.Where(m => m.Group == methodGroupName)
.ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient)));
}
示例8: 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);
ProcessClientRequestIdExtension(serviceClient);
UpdateHeadMethods(serviceClient);
ParseODataExtension(serviceClient);
ProcessGlobalParameters(serviceClient);
FlattenModels(serviceClient);
FlattenMethodParameters(serviceClient, settings);
ParameterGroupExtensionHelper.AddParameterGroups(serviceClient);
AddLongRunningOperations(serviceClient);
AddAzureProperties(serviceClient);
SetDefaultResponses(serviceClient);
AddPageableMethod(serviceClient, codeNamer);
}
示例9: Generate
/// <summary>
/// Generates Go code for service client.
/// </summary>
/// <param name="serviceClient"></param>
/// <returns></returns>
public override async Task Generate(ServiceClient serviceClient)
{
string packageName = GoCodeNamer.PackageNameFromNamespace(Settings.Namespace);
// Service client
var serviceClientTemplate = new ServiceClientTemplate
{
Model = new ServiceClientTemplateModel(serviceClient, packageName),
};
await Write(serviceClientTemplate, GoCodeNamer.FormatFileName("client"));
foreach (var methodGroupName in serviceClient.MethodGroups)
{
var groupedMethodTemplate = new MethodGroupTemplate
{
Model = new MethodGroupTemplateModel(serviceClient, packageName, methodGroupName),
};
await Write(groupedMethodTemplate, GoCodeNamer.FormatFileName(methodGroupName.ToLowerInvariant()));
}
// Models
var modelsTemplate = new ModelsTemplate
{
Model = new ModelsTemplateModel(serviceClient, packageName),
};
await Write(modelsTemplate, GoCodeNamer.FormatFileName("models"));
// Version
var versionTemplate = new VersionTemplate
{
Model = new VersionTemplateModel(serviceClient, packageName),
};
await Write(versionTemplate, GoCodeNamer.FormatFileName("version"));
}
示例10: Generate
public override async Task Generate(ServiceClient serviceClient)
{
var viewModel = new SampleViewModel();
var model = new SampleModel();
model.Model = viewModel;
await Write(model, Path.Combine(Settings.ModelsName, "Pet.cs"));
}
示例11: VersionTemplateModel
public VersionTemplateModel(ServiceClient serviceClient, string packageName, string[] version)
{
this.LoadFrom(serviceClient);
PackageName = packageName;
Version = version;
}
示例12: ServiceClientTemplateModel
public ServiceClientTemplateModel(ServiceClient serviceClient, string packageName, string methodGroupName = null)
{
this.LoadFrom(serviceClient);
MethodGroupName = methodGroupName == null
? string.Empty
: methodGroupName;
PackageName = packageName == null
? string.Empty
: packageName;
BaseClient = "ManagementClient";
ClientName = string.IsNullOrEmpty(MethodGroupName)
? BaseClient
: MethodGroupName.IsNamePlural(PackageName)
? MethodGroupName + "Client"
: (MethodGroupName + "Client").TrimPackageName(PackageName);
MethodScope = new MethodScopeProvider();
MethodTemplateModels = new List<MethodTemplateModel>();
Methods.Where(m => m.BelongsToGroup(MethodGroupName, PackageName))
.OrderBy(m => m.Name)
.ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, ClientName, PackageName, new MethodScopeProvider())));
Documentation = string.Format("Package {0} implements the Azure ARM {1} service API version {2}.\n\n{3}", PackageName, ServiceName, ApiVersion,
!string.IsNullOrEmpty(Documentation) ? Documentation.UnwrapAnchorTags() : "");
ClientDocumentation = string.Format("{0} is the base client for {1}.", ClientName, ServiceName);
}
示例13: 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);
}
}
示例14: NameCollisionTestWithoutNamespace
public void NameCollisionTestWithoutNamespace()
{
var serviceClient = new ServiceClient();
serviceClient.Name = "azure always rocks!";
var customObjectType = new CompositeType();
customObjectType.Name = "azure always rocks!";
var baseType = new CompositeType();
baseType.Name = "azure always rocks!";
serviceClient.Methods.Add(new Method
{
Name = "azure always rocks!",
Group = "azure always rocks!",
ReturnType = new Response(customObjectType, null)
});
serviceClient.ModelTypes.Add(customObjectType);
serviceClient.ModelTypes.Add(baseType);
var framework = new CSharpCodeNamer();
framework.ResolveNameCollisions(serviceClient, null, null);
Assert.Equal("azure always rocks!Client", serviceClient.Name);
Assert.Equal("azure always rocks!Operations", serviceClient.MethodGroups.First());
Assert.Equal("azure always rocks!", serviceClient.Methods[0].Name);
Assert.Equal("azure always rocks!", serviceClient.ModelTypes.First(m => m.Name == "azure always rocks!").Name);
}
示例15: AzureServiceClientTemplateModel
public AzureServiceClientTemplateModel(ServiceClient serviceClient, bool internalConstructors)
: base(serviceClient, internalConstructors)
{
// TODO: Initialized in the base constructor. Why Clear it?
MethodTemplateModels.Clear();
Methods.Where(m => m.Group == null)
.ForEach(m => MethodTemplateModels.Add(new AzureMethodTemplateModel(m, serviceClient, SyncMethodsGenerationMode.None)));
}