12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using System;
- using System.Collections.Generic;
- using Luticate2.Auth.Auth.Business;
- using Luticate2.Auth.Auth.DataAccess;
- using Luticate2.Auth.Auth.DataAccess.Converters;
- using Luticate2.Auth.Auth.DataAccess.Models;
- using Luticate2.Auth.Auth.Dbo;
- using Luticate2.Auth.ConsoleSample.Commands;
- using Luticate2.Auth.Utils.Business.Converters;
- using Luticate2.Auth.Utils.Business.Utils;
- using Luticate2.Auth.Utils.Interfaces;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.Extensions.DependencyInjection;
- using NClap.Metadata;
- using NClap.Repl;
-
- namespace Luticate2.Auth.ConsoleSample
- {
- enum CommandsEnum
- {
- [Command(typeof(ListCommand), Description = "Lists Luticate2 items", LongName = "ls", ShortName = "l")]
- ListItems,
-
- [Command(typeof(CreateCommand), Description = "Creates Luticate2 items", LongName = "create", ShortName = "c")]
- CreateItems,
-
- [Command(typeof(ExitCommand), Description = "Exits the shell")]
- Exit
- }
-
- class Program
- {
- public static IServiceProvider ServiceProvider;
-
- static void Main(string[] args)
- {
- IServiceCollection services = new ServiceCollection();
-
- services.AddLuObjectConverterDescriptors();
- // DB Read
- services.AddSingleton<ILuObjectConverterDescriptor<LuObjectsMetadataDbo, LuObjectsMetadata>, LuObjectsMetadataDboDescriptor>();
- services.AddSingleton<ILuObjectConverterDescriptor<LuGroupDbo, LuGroups>, LuGroupsDboDescriptor>();
- // DB Write
-
- services.AddLuObjectConverters();
- // DB read
- services.AddLuObjectConverterPoco<LuObjectsMetadata, LuObjectsMetadataDbo>();
- services.AddLuObjectConverterPoco<LuGroups, LuGroupDbo>();
- // DB Write
-
- // DB filter/orderBy
- services.AddSingleton<ILuConvertersTypeConverter>(new LuConvertersTypeConverter(new Dictionary<Type, Type>
- {
- {typeof(LuGroupDbo), typeof(LuGroups)}
- }));
-
- services.AddScoped<LuGroupsBusiness>();
-
- services.AddLuOptions();
- services.Configure<LuExpressionUtils.LuExpressionParserOptions>(options =>
- {
- options.ScriptOptions = options.ScriptOptions.AddReferences(typeof(Program).Assembly);
- });
-
- services.AddDbContext<Luticate2DbContext>(options =>
- {
- options.UseNpgsql(@"Host=localhost;Database=luticate2;Username=dev;Password=dev");
- options.UseInternalServiceProvider(new ServiceCollection()
- .AddEntityFrameworkNpgsql()
- .BuildServiceProvider());
- }, ServiceLifetime.Transient);
-
- ServiceProvider = services.BuildServiceProvider();
-
- var loop = new Loop(typeof(CommandsEnum));
- loop.Execute();
- }
- }
- }
|