//-----------------------------------------------------------------------
// <copyright file="MainWindowModel.cs" company="NSwag">
//     Copyright (c) Rico Suter. All rights reserved.
// </copyright>
// <license>https://github.com/RicoSuter/NSwag/blob/master/LICENSE.md</license>
// <author>Rico Suter, mail@rsuter.com</author>
//-----------------------------------------------------------------------

using NJsonSchema.CodeGeneration.CSharp;
using NSwag.Commands;
using NSwag.Commands.CodeGeneration;

namespace NSwagStudio.ViewModels.CodeGenerators
{
    public class SwaggerToCSharpClientGeneratorViewModel : ViewModelBase
    {
        private string _clientCode;
        private OpenApiToCSharpClientCommand _command = new OpenApiToCSharpClientCommand();

        /// <summary>Gets the settings.</summary>
        public OpenApiToCSharpClientCommand Command
        {
            get => _command;
            set
            {
                if (Set(ref _command, value))
                    RaiseAllPropertiesChanged();
            }
        }

        /// <summary>Gets the list of operation modes. </summary>
        public OperationGenerationMode[] OperationGenerationModes { get; } = Enum.GetNames(typeof(OperationGenerationMode))
            .Select(t => (OperationGenerationMode)Enum.Parse(typeof(OperationGenerationMode), t))
            .ToArray();

        /// <summary>Gets the list of class styles. </summary>
        public CSharpClassStyle[] ClassStyles { get; } = Enum.GetNames(typeof(CSharpClassStyle))
            .Select(t => (CSharpClassStyle)Enum.Parse(typeof(CSharpClassStyle), t))
            .ToArray();

        /// <summary>Gets the list of JSON libraries. </summary>
        public CSharpJsonLibrary[] JsonLibraries { get; } = Enum.GetNames(typeof(CSharpJsonLibrary))
            .Select(t => (CSharpJsonLibrary)Enum.Parse(typeof(CSharpJsonLibrary), t))
            .ToArray();

        /// <summary>Gets the list of JSON polymorphic serialization styles. </summary>
        public CSharpJsonPolymorphicSerializationStyle[] JsonPolymorphicSerializationStyles { get; } = Enum.GetNames(typeof(CSharpJsonPolymorphicSerializationStyle))
            .Select(t => (CSharpJsonPolymorphicSerializationStyle)Enum.Parse(typeof(CSharpJsonPolymorphicSerializationStyle), t))
            .ToArray();

        /// <summary>Gets new line behaviors. </summary>
        public NewLineBehavior[] NewLineBehaviors { get; } = Enum.GetNames(typeof(NewLineBehavior))
            .Select(t => (NewLineBehavior)Enum.Parse(typeof(NewLineBehavior), t))
            .ToArray();

        /// <summary>Gets or sets the client code. </summary>
        public string ClientCode
        {
            get => _clientCode;
            set => Set(ref _clientCode, value);
        }
    }
}
