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.

LuticateExtensions.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Collections.Generic;
  2. using Luticate2.Auth.Business;
  3. using Luticate2.Auth.DataAccess;
  4. using Luticate2.Auth.Middlewares;
  5. using Luticate2.Utils.Controllers;
  6. using Luticate2.Utils.Dbo.OrderBy;
  7. using Microsoft.AspNetCore.Builder;
  8. using Microsoft.AspNetCore.Http;
  9. using Microsoft.AspNetCore.Mvc;
  10. using Microsoft.Extensions.DependencyInjection;
  11. namespace Luticate2.Auth.Controllers
  12. {
  13. public static class LuticateExtensions
  14. {
  15. public static IServiceCollection AddLuticate(this IServiceCollection services)
  16. {
  17. services.AddSingleton<LuGroupsController>();
  18. services.AddSingleton<LuGroupsBusiness>();
  19. services.AddSingleton<LuGroupsDataAccess>();
  20. services.AddSingleton<LuUsersController>();
  21. services.AddDbContext<LuDatabaseContext>();
  22. return services;
  23. }
  24. public static IMvcBuilder AddLuticate(this IMvcBuilder builder)
  25. {
  26. // builder.AddApplicationPart(typeof(LuController).GetTypeInfo().Assembly)
  27. // .AddControllersAsServices();
  28. builder.Services.Configure<MvcOptions>(
  29. options => options.ModelBinderProviders.Insert(0, new LuOrderByBinderProvider()));
  30. return builder;
  31. }
  32. public static IApplicationBuilder UseLuticate(this IApplicationBuilder app)
  33. {
  34. app.UseMiddleware<LuAuthMiddleware>();
  35. return app;
  36. }
  37. public static object GetLuCurrentUser(this HttpContext context)
  38. {
  39. return context.GetLuItems()["currentUser"];//TODO
  40. }
  41. }
  42. }