You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Program.cs 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using Luticate2.Auth.Auth.Business;
  3. using Luticate2.Auth.Auth.DataAccess;
  4. using Luticate2.Auth.ConsoleSample.Commands;
  5. using Luticate2.Auth.Utils.Business.Converters;
  6. using Microsoft.EntityFrameworkCore;
  7. using Microsoft.Extensions.DependencyInjection;
  8. using NClap.Metadata;
  9. using NClap.Repl;
  10. namespace Luticate2.Auth.ConsoleSample
  11. {
  12. enum CommandsEnum
  13. {
  14. [Command(typeof(ListCommand), Description = "Lists Luticate2 items", LongName = "ls", ShortName = "l")]
  15. ListItems,
  16. [Command(typeof(CreateCommand), Description = "Creates Luticate2 items", LongName = "create", ShortName = "c")]
  17. CreateItems,
  18. [Command(typeof(ExitCommand), Description = "Exits the shell")]
  19. Exit
  20. }
  21. class Program
  22. {
  23. public static IServiceProvider ServiceProvider;
  24. static void Main(string[] args)
  25. {
  26. IServiceCollection services = new ServiceCollection();
  27. services.AddLuObjectConverterDescriptors();
  28. services.AddLuObjectConverters();
  29. services.AddScoped<LuGroupsBusiness>();
  30. services.AddDbContext<Luticate2DbContext>(options =>
  31. {
  32. options.UseNpgsql(@"Host=localhost;Database=luticate2;Username=dev;Password=dev");
  33. options.UseInternalServiceProvider(new ServiceCollection()
  34. .AddEntityFrameworkNpgsql()
  35. .BuildServiceProvider());
  36. }, ServiceLifetime.Transient);
  37. ServiceProvider = services.BuildServiceProvider();
  38. var loop = new Loop(typeof(CommandsEnum));
  39. loop.Execute();
  40. }
  41. }
  42. }