using System.IO.Abstractions;
using System.Reflection;
using BO.AppServer.Metadata.Dto;
using Quadarax.Foundation.Core.Data.Interface.Entity.Dto;
using Quadarax.Foundation.Core.Json;
using Quadarax.Foundation.Core.Object.Extensions;
using Quadarax.Foundation.Core.QConsole;
using Quadarax.Foundation.Core.QConsole.Configuration;
using Quadarax.Foundation.Core.QConsole.Context;
using Quadarax.Foundation.Core.Reflection.Extensions;
using Binder = Quadarax.Foundation.Core.Json.Binder;

namespace BO.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            var str = new StructureRDto();
            var x = str.GetAllPropertyValues();
            int a = 0;
            */
            /*
            document_add -arts:doc1_file1.bin;doc1_file2.bin -force -user:test -dbg -dump

            var user = new UserCDto()
            {
                Name = "foo",
                Email = "fii",
                LangLcid = 123,
                Password = "frr",
                Roles = new[] { "So", "Fa" }
            };
            var _binder = new Binder(new FileSystem());
            _binder.SerializerOptions.IgnoreReadOnlyProperties = true;
            _binder.SerializerOptions.IgnoreNullValues = true;
            var res = _binder.SaveToString(user);
            */
            /*
            var content = "{\"value\":null,\"isSuccess\":false,\"errors\":[{\"message\":\"User 'Console' has no permission to login in. Access denied!\",\"code\":1200}]}";
            //var content = "{\"isSuccess\":false,\"values\":[{\"message\":\"User 'Console' has no permission to login in. Access denied!\",\"code\":1200}]}";
            var _binder = new Binder(new FileSystem());
            _binder.SerializerOptions.IgnoreReadOnlyProperties = true;
            _binder.SerializerOptions.IgnoreNullValues = true;
            var res = _binder.LoadFromString(content, typeof(ResultValueDto<UserRDto>));
            */
            /*
            var dto = new ResultValueDto<AuthDto>();
            dto.Value.Ticket = "foo";
            var bnd = new Binder(new FileSystem());
            //bnd.SerializerOptions.IgnoreReadOnlyProperties = true;
            var str = bnd.SaveToString(dto);
            var dto2 = bnd.LoadFromString(str, typeof(ResultValueDto<AuthDto>));
            //var dto2 = new ResultValueDto<AuthDto>();
            //bnd.LoadFromStringTo(str, dto2, typeof(ResultValueDto<AuthDto>));
            */

            var config = new StartupConfiguration("BO Console", Assembly.GetExecutingAssembly().GetName().Version);
            config.ConsoleCopyright = Assembly.GetExecutingAssembly().GetCopyright();
            config.AllowInteractive = false;
            config.WaitOnKeyInNonInteractiveMode = false;
            config.CommandDefinitionAssebmly = new Assembly[]{Assembly.GetEntryAssembly()};
            config.DisableDefaultCommands();
            config.ShowStatusOnEveryCommand = false;
            config.IsConsoleDebug = false;

            var console = new Engine(config, new DefualtEngineContext(), args);
            console.Start();

        }
    }
}
