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 4.1KB

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