Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Program.cs 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using Luticate2.Auth.Auth.Business;
  4. using Luticate2.Auth.Auth.DataAccess;
  5. using Luticate2.Auth.Auth.DataAccess.Converters;
  6. using Luticate2.Auth.Auth.DataAccess.Models;
  7. using Luticate2.Auth.Auth.Dbo;
  8. using Luticate2.Auth.ConsoleSample.Commands;
  9. using Luticate2.Auth.Utils.Business.Converters;
  10. using Luticate2.Auth.Utils.Business.Utils;
  11. using Luticate2.Auth.Utils.Interfaces;
  12. using Microsoft.EntityFrameworkCore;
  13. using Microsoft.Extensions.DependencyInjection;
  14. using NClap.Metadata;
  15. using NClap.Repl;
  16. namespace Luticate2.Auth.ConsoleSample
  17. {
  18. enum CommandsEnum
  19. {
  20. [Command(typeof(ListCommand), Description = "Lists Luticate2 items", LongName = "ls", ShortName = "l")]
  21. ListItems,
  22. [Command(typeof(CreateCommand), Description = "Creates Luticate2 items", LongName = "create", ShortName = "c")]
  23. CreateItems,
  24. [Command(typeof(ExitCommand), Description = "Exits the shell")]
  25. Exit
  26. }
  27. class Program
  28. {
  29. public static IServiceProvider ServiceProvider;
  30. static void Main(string[] args)
  31. {
  32. IServiceCollection services = new ServiceCollection();
  33. services.AddLuObjectConverterDescriptors();
  34. // DB Read
  35. services.AddSingleton<ILuObjectConverterDescriptor<LuObjectsMetadataDbo, LuObjectsMetadata>, LuObjectsMetadataDboDescriptor>();
  36. services.AddSingleton<ILuObjectConverterDescriptor<LuGroupDbo, LuGroups>, LuGroupsDboDescriptor>();
  37. // DB Write
  38. services.AddLuObjectConverters();
  39. // DB read
  40. services.AddLuObjectConverterPoco<LuObjectsMetadata, LuObjectsMetadataDbo>();
  41. services.AddLuObjectConverterPoco<LuGroups, LuGroupDbo>();
  42. // DB Write
  43. // DB filter/orderBy
  44. services.AddSingleton<ILuConvertersTypeConverter>(new LuConvertersTypeConverter(new Dictionary<Type, Type>
  45. {
  46. {typeof(LuGroupDbo), typeof(LuGroups)}
  47. }));
  48. services.AddScoped<LuGroupsBusiness>();
  49. services.AddLuOptions();
  50. services.Configure<LuExpressionUtils.LuExpressionParserOptions>(options =>
  51. {
  52. options.ScriptOptions = options.ScriptOptions.AddReferences(typeof(Program).Assembly);
  53. });
  54. services.AddDbContext<Luticate2DbContext>(options =>
  55. {
  56. options.UseNpgsql(@"Host=localhost;Database=luticate2;Username=dev;Password=dev");
  57. options.UseInternalServiceProvider(new ServiceCollection()
  58. .AddEntityFrameworkNpgsql()
  59. .BuildServiceProvider());
  60. }, ServiceLifetime.Transient);
  61. ServiceProvider = services.BuildServiceProvider();
  62. var loop = new Loop(typeof(CommandsEnum));
  63. loop.Execute();
  64. }
  65. }
  66. }