Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Program.cs 4.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using Luticate2.Auth.Auth.Business;
  3. using Luticate2.Auth.Auth.Business.PartialObjectCopier;
  4. using Luticate2.Auth.Auth.DataAccess;
  5. using Luticate2.Auth.Auth.DataAccess.Models;
  6. using Luticate2.Auth.Auth.Dbo;
  7. using Luticate2.Auth.ConsoleSample.Commands;
  8. using Luticate2.Auth.Utils.Interfaces;
  9. using Microsoft.EntityFrameworkCore;
  10. using Microsoft.Extensions.DependencyInjection;
  11. using NClap.Metadata;
  12. using NClap.Repl;
  13. namespace Luticate2.Auth.ConsoleSample
  14. {
  15. enum CommandsEnum
  16. {
  17. [Command(typeof(ListCommand), Description = "Lists Luticate2 items", LongName = "ls", ShortName = "l")]
  18. ListItems,
  19. [Command(typeof(CreateCommand), Description = "Creates Luticate2 items", LongName = "create", ShortName = "c")]
  20. CreateItems,
  21. [Command(typeof(ExitCommand), Description = "Exits the shell")]
  22. Exit
  23. }
  24. class Program
  25. {
  26. public static IServiceProvider ServiceProvider;
  27. // protected static void AddILuExpressionConverter<TTypeFrom, TTypeTo, TTypeImpl>(IServiceCollection services)
  28. // where TTypeImpl : class, ILuExpressionConverter<TTypeFrom, TTypeTo>
  29. // {
  30. // services.AddSingleton<ILuExpressionConverter<TTypeFrom, TTypeTo>, TTypeImpl>();
  31. // services.TryAddSingleton<ILuExpressionConverter<TTypeFrom>, TTypeImpl>();
  32. // }
  33. static void Main(string[] args)
  34. {
  35. IServiceCollection services = new ServiceCollection();
  36. services.AddScoped<LuGroupsBusiness>();
  37. services.AddSingleton<ILuPartialObjectCopier<LuObjectsMetadata, LuObjectsMetadataDbo>, LuPOCObjectsMetadataToDbo>();
  38. services.AddSingleton<ILuPartialObjectCopier<LuGroups, LuGroupDbo>, LuPOCGroupsToDbo>();
  39. services.AddSingleton<ILuPartialObjectCopier<LuGroupDbo, LuGroups>, LuPOCGroupsToModel>();
  40. // services.AddSingleton<ILuDboModelExpressionConverter<TestDbo1, TestModel1>, LuDMECTest1>();
  41. // AddILuExpressionConverter<LuGroupDbo, LuGroups, LuDMECGroupsToModel>(services);
  42. // AddILuExpressionConverter<string, string, LuExpressionConverterIdentity<string>>(services);
  43. // AddILuExpressionConverter<Guid, Guid, LuExpressionConverterIdentity<Guid>>(services);
  44. // AddILuExpressionConverter<bool, bool, LuExpressionConverterIdentity<bool>>(services);
  45. // services.AddSingleton<ILuFieldsExpressions<LuObjectsMetadataDbo, LuObjectsMetadata>, LuFieldsExpressionsLuMetadataDboLuMetadata>();
  46. // services.AddSingleton<ILuFieldsExpressions<LuGroupDbo, LuGroups>, LuFieldsExpressionsLuGroupDboLuGroups>();
  47. //
  48. // services.AddSingleton<ILuFieldsExpressions<string, string>, LuFieldsExpressionsString>();
  49. // services.AddSingleton<ILuFieldsExpressions<int, int>, LuFieldsExpressions<int, int>>();
  50. // services.AddSingleton<ILuFieldsExpressions<Guid, Guid>, LuFieldsExpressions<Guid, Guid>>();
  51. //
  52. // services.AddSingleton<ILuFieldsExpressions<DateTime, DateTime>, LuFieldsExpressions<DateTime, DateTime>>();
  53. // services.AddSingleton<ILuFieldsExpressions<DateTimeOffset, DateTimeOffset>, LuFieldsExpressions<DateTimeOffset, DateTimeOffset>>();
  54. // services.AddSingleton<ILuFieldsExpressions<DateTime, DateTimeOffset>, LuFieldsExpressions<DateTime, DateTimeOffset>>();
  55. // services.AddSingleton<ILuFieldsExpressions<DateTimeOffset, DateTime>, LuFieldsExpressions<DateTimeOffset, DateTime>>();
  56. //
  57. // services.AddSingleton<ILuFieldsExpressions<DateTime?, DateTime?>, LuFieldsExpressions<DateTime?, DateTime?>>();
  58. // services.AddSingleton<ILuFieldsExpressions<DateTimeOffset?, DateTimeOffset?>, LuFieldsExpressions<DateTimeOffset?, DateTimeOffset?>>();
  59. // services.AddSingleton<ILuFieldsExpressions<DateTime?, DateTimeOffset?>, LuFieldsExpressions<DateTime?, DateTimeOffset?>>();
  60. // services.AddSingleton<ILuFieldsExpressions<DateTimeOffset?, DateTime?>, LuFieldsExpressions<DateTimeOffset?, DateTime?>>();
  61. services.AddDbContext<Luticate2DbContext>(options =>
  62. {
  63. options.UseNpgsql(@"Host=localhost;Database=luticate2;Username=dev;Password=dev");
  64. options.UseInternalServiceProvider(new ServiceCollection()
  65. .AddEntityFrameworkNpgsql()
  66. .BuildServiceProvider());
  67. }, ServiceLifetime.Transient);
  68. ServiceProvider = services.BuildServiceProvider();
  69. var loop = new Loop(typeof(CommandsEnum));
  70. loop.Execute();
  71. }
  72. }
  73. }