Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Program.cs 4.6KB

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