Removed ClientModel layer. Renamed output object models to appropriate names.

This commit is contained in:
Michael Yanni 2020-01-12 11:44:29 -08:00
Родитель 580efe2398
Коммит c62a95aca2
12 изменённых файлов: 11 добавлений и 23 удалений

Просмотреть файл

@ -29,9 +29,7 @@ namespace AutoRest.CSharp.V3.Plugins
var modelBuilder = new ModelBuilder(GetMediaTypes(codeModel));
var models = schemas.Select(modelBuilder.BuildModel).ToArray();
var clients = codeModel.OperationGroups.Select(ClientBuilder.BuildClient).ToArray();
var typeProviders = models.OfType<ISchemaTypeProvider>().ToArray();
var typeFactory = new TypeFactory(configuration.Namespace, typeProviders);
var typeFactory = new TypeFactory(configuration.Namespace, models);
var modelWriter = new ModelWriter(typeFactory);
var writer = new ClientWriter(typeFactory);

Просмотреть файл

@ -21,7 +21,7 @@ namespace AutoRest.CSharp.V3.CodeGen
_typeFactory = typeFactory;
}
public void WriteModel(CodeWriter writer, ClientModel model)
public void WriteModel(CodeWriter writer, ISchemaTypeProvider model)
{
switch (model)
{

Просмотреть файл

@ -22,7 +22,7 @@ namespace AutoRest.CSharp.V3.CodeGen
_typeFactory = typeFactory;
}
public void WriteSerialization(CodeWriter writer, ClientModel schema)
public void WriteSerialization(CodeWriter writer, ISchemaTypeProvider schema)
{
switch (schema)
{

Просмотреть файл

@ -22,7 +22,7 @@ namespace AutoRest.CSharp.V3.ClientModels
_mediaTypes = mediaTypes;
}
private static ClientModel BuildClientEnum(SealedChoiceSchema sealedChoiceSchema) => new ClientEnum(
private static ISchemaTypeProvider BuildClientEnum(SealedChoiceSchema sealedChoiceSchema) => new ClientEnum(
sealedChoiceSchema,
sealedChoiceSchema.CSharpName(),
CreateDescription(sealedChoiceSchema),
@ -31,7 +31,7 @@ namespace AutoRest.CSharp.V3.ClientModels
CreateDescription(c),
ClientModelBuilderHelpers.StringConstant(c.Value))));
private static ClientModel BuildClientEnum(ChoiceSchema choiceSchema) => new ClientEnum(
private static ISchemaTypeProvider BuildClientEnum(ChoiceSchema choiceSchema) => new ClientEnum(
choiceSchema,
choiceSchema.CSharpName(),
CreateDescription(choiceSchema),
@ -41,7 +41,7 @@ namespace AutoRest.CSharp.V3.ClientModels
ClientModelBuilderHelpers.StringConstant(c.Value))),
true);
private ClientModel BuildClientObject(ObjectSchema objectSchema)
private ISchemaTypeProvider BuildClientObject(ObjectSchema objectSchema)
{
ClientTypeReference? inheritsFromTypeReference = null;
DictionarySchema? inheritedDictionarySchema = null;
@ -127,7 +127,7 @@ namespace AutoRest.CSharp.V3.ClientModels
)).ToArray();
}
public ClientModel BuildModel(Schema schema) => schema switch
public ISchemaTypeProvider BuildModel(Schema schema) => schema switch
{
SealedChoiceSchema sealedChoiceSchema => BuildClientEnum(sealedChoiceSchema),
ChoiceSchema choiceSchema => BuildClientEnum(choiceSchema),

Просмотреть файл

@ -6,7 +6,7 @@ using AutoRest.CSharp.V3.Pipeline.Generated;
namespace AutoRest.CSharp.V3.ClientModels
{
internal class ClientEnum : ClientModel, ISchemaTypeProvider
internal class ClientEnum : ISchemaTypeProvider
{
public ClientEnum(Schema schema, string name, string? description, IEnumerable<ClientEnumValue> values, bool isStringBased = false)
{
@ -19,7 +19,7 @@ namespace AutoRest.CSharp.V3.ClientModels
public bool IsStringBased { get; }
public Schema Schema { get; }
public override string Name { get; }
public string Name { get; }
public string? Description { get; }
public IList<ClientEnumValue> Values { get; }
}

Просмотреть файл

@ -1,10 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace AutoRest.CSharp.V3.ClientModels
{
internal abstract class ClientModel
{
public abstract string Name { get; }
}
}

Просмотреть файл

@ -7,7 +7,7 @@ using AutoRest.CSharp.V3.Pipeline.Generated;
namespace AutoRest.CSharp.V3.ClientModels
{
internal class ClientObject : ClientModel, ISchemaTypeProvider
internal class ClientObject : ISchemaTypeProvider
{
public ClientObject(Schema schema, string name, string? description, SchemaTypeReference? inherits, IEnumerable<ClientObjectProperty> properties, ClientObjectDiscriminator? discriminator, DictionaryTypeReference? implementsDictionary, ObjectSerialization[] serializations)
{
@ -21,7 +21,7 @@ namespace AutoRest.CSharp.V3.ClientModels
Properties = new List<ClientObjectProperty>(properties);
}
public override string Name { get; }
public string Name { get; }
public string? Description { get; }
public Schema Schema { get; }
public SchemaTypeReference? Inherits { get; }