1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using System;
- using System.Collections.Generic;
- using Luticate2.Auth.Business.Auth;
- using Luticate2.Auth.Business.Auth.DMEC;
- using Luticate2.Auth.Business.Auth.PartialObjectCopier;
- using Luticate2.Auth.Business.Fields.DMEC;
- using Luticate2.Auth.ConsoleSample.Commands;
- using Luticate2.Auth.DataAccess;
- using Luticate2.Auth.DataAccess.Models;
- using Luticate2.Auth.Dbo.Auth;
- using Luticate2.Auth.Interfaces;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.DependencyInjection.Extensions;
- 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;
-
- protected static void AddILuExpressionConverter<TTypeFrom, TTypeTo, TTypeImpl>(IServiceCollection services)
- where TTypeImpl : class, ILuExpressionConverter<TTypeFrom, TTypeTo>
- {
- services.AddSingleton<ILuExpressionConverter<TTypeFrom, TTypeTo>, TTypeImpl>();
- services.TryAddSingleton<ILuExpressionConverter<TTypeFrom>, TTypeImpl>();
- }
-
- static void Main(string[] args)
- {
- IServiceCollection services = new ServiceCollection();
-
- services.AddScoped<LuGroupsBusiness>();
-
- services.AddSingleton<ILuPartialObjectCopier<LuObjectsMetadata, LuObjectsMetadataDbo>, LuPOCObjectsMetadataToDbo>();
- services.AddSingleton<ILuPartialObjectCopier<LuGroups, LuGroupDbo>, LuPOCGroupsToDbo>();
- services.AddSingleton<ILuPartialObjectCopier<LuGroupDbo, LuGroups>, LuPOCGroupsToModel>();
-
-
- // services.AddSingleton<ILuDboModelExpressionConverter<TestDbo1, TestModel1>, LuDMECTest1>();
- AddILuExpressionConverter<LuGroupDbo, LuGroups, LuDMECGroupsToModel>(services);
- AddILuExpressionConverter<string, string, LuExpressionConverterIdentity<string>>(services);
- AddILuExpressionConverter<Guid, Guid, LuExpressionConverterIdentity<Guid>>(services);
- AddILuExpressionConverter<bool, bool, LuExpressionConverterIdentity<bool>>(services);
-
-
- // services.AddSingleton<ILuFieldsExpressions<LuObjectsMetadataDbo, LuObjectsMetadata>, LuFieldsExpressionsLuMetadataDboLuMetadata>();
- // services.AddSingleton<ILuFieldsExpressions<LuGroupDbo, LuGroups>, LuFieldsExpressionsLuGroupDboLuGroups>();
- //
- // services.AddSingleton<ILuFieldsExpressions<string, string>, LuFieldsExpressionsString>();
- // services.AddSingleton<ILuFieldsExpressions<int, int>, LuFieldsExpressions<int, int>>();
- // services.AddSingleton<ILuFieldsExpressions<Guid, Guid>, LuFieldsExpressions<Guid, Guid>>();
- //
- // services.AddSingleton<ILuFieldsExpressions<DateTime, DateTime>, LuFieldsExpressions<DateTime, DateTime>>();
- // services.AddSingleton<ILuFieldsExpressions<DateTimeOffset, DateTimeOffset>, LuFieldsExpressions<DateTimeOffset, DateTimeOffset>>();
- // services.AddSingleton<ILuFieldsExpressions<DateTime, DateTimeOffset>, LuFieldsExpressions<DateTime, DateTimeOffset>>();
- // services.AddSingleton<ILuFieldsExpressions<DateTimeOffset, DateTime>, LuFieldsExpressions<DateTimeOffset, DateTime>>();
- //
- // services.AddSingleton<ILuFieldsExpressions<DateTime?, DateTime?>, LuFieldsExpressions<DateTime?, DateTime?>>();
- // services.AddSingleton<ILuFieldsExpressions<DateTimeOffset?, DateTimeOffset?>, LuFieldsExpressions<DateTimeOffset?, DateTimeOffset?>>();
- // services.AddSingleton<ILuFieldsExpressions<DateTime?, DateTimeOffset?>, LuFieldsExpressions<DateTime?, DateTimeOffset?>>();
- // services.AddSingleton<ILuFieldsExpressions<DateTimeOffset?, DateTime?>, LuFieldsExpressions<DateTimeOffset?, DateTime?>>();
-
- 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();
- }
- }
- }
|