2020-05-22 21:19:49 +02:00
|
|
|
using FluentValidation;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2020-05-22 15:06:17 +02:00
|
|
|
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
2020-05-22 21:19:49 +02:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2020-05-21 23:44:43 +02:00
|
|
|
using System.Collections.Generic;
|
2020-05-22 15:06:17 +02:00
|
|
|
using System.Linq;
|
2020-05-21 23:44:43 +02:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using zero.Core.Api;
|
|
|
|
|
using zero.Core.Entities;
|
2020-08-27 11:41:40 +02:00
|
|
|
using zero.Core.Extensions;
|
2020-08-26 11:10:52 +02:00
|
|
|
using zero.Core.Utils;
|
2020-08-27 14:22:13 +02:00
|
|
|
using zero.Web.Filters;
|
2020-05-21 23:44:43 +02:00
|
|
|
|
|
|
|
|
namespace zero.Debug.Controllers
|
|
|
|
|
{
|
2020-08-27 14:22:13 +02:00
|
|
|
[ServiceFilter(typeof(ModelStateValidationFilterAttribute))]
|
2020-05-21 23:44:43 +02:00
|
|
|
public class TestController : Controller
|
|
|
|
|
{
|
2020-05-22 15:06:17 +02:00
|
|
|
private readonly IActionDescriptorCollectionProvider _actionDescriptorCollectionProvider;
|
2020-05-21 23:44:43 +02:00
|
|
|
|
2020-05-22 15:06:17 +02:00
|
|
|
|
2020-05-24 18:40:30 +02:00
|
|
|
public TestController(IActionDescriptorCollectionProvider actionDescriptorCollectionProvider)
|
2020-05-21 23:44:43 +02:00
|
|
|
{
|
2020-05-22 15:06:17 +02:00
|
|
|
_actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
|
2020-05-21 23:44:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-05-22 21:19:49 +02:00
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Services()
|
|
|
|
|
{
|
|
|
|
|
List<object> items = new List<object>();
|
|
|
|
|
|
|
|
|
|
foreach (var service in Startup.Services)
|
|
|
|
|
{
|
|
|
|
|
if (!service.ServiceType.FullName.StartsWith("zero.") && (service.ImplementationType == null || !service.ImplementationType.FullName.StartsWith("zero.")))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
items.Add(new
|
|
|
|
|
{
|
|
|
|
|
name = service.ServiceType.FullName,
|
|
|
|
|
lifetime = service.Lifetime,
|
|
|
|
|
instance = service.ImplementationType?.FullName
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-25 16:15:33 +02:00
|
|
|
return Json(new
|
|
|
|
|
{
|
|
|
|
|
count = items.Count,
|
|
|
|
|
items
|
|
|
|
|
});
|
2020-05-22 21:19:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-05-24 19:05:59 +02:00
|
|
|
[HttpGet]
|
2020-05-24 20:52:09 +02:00
|
|
|
public async Task<IActionResult> GetTranslations([FromServices] ITranslationsApi api)
|
2020-05-24 19:05:59 +02:00
|
|
|
{
|
2020-05-24 20:52:09 +02:00
|
|
|
return Json(await api.GetAll());
|
2020-05-24 19:05:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-08-26 11:10:52 +02:00
|
|
|
|
2020-05-22 21:19:49 +02:00
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Things([FromServices] IValidator<Application> appValidator)
|
|
|
|
|
{
|
|
|
|
|
return Ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-08-27 11:41:40 +02:00
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Clone([FromServices] IRecycledEntity blueprint)
|
|
|
|
|
{
|
|
|
|
|
IRecycledEntity entity = blueprint.Clone();
|
|
|
|
|
return Json(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-08-27 14:22:13 +02:00
|
|
|
[HttpPost]
|
|
|
|
|
public IActionResult SaveTest([FromBody] IPage model) => Json(model);
|
|
|
|
|
|
|
|
|
|
|
2020-08-27 11:41:40 +02:00
|
|
|
|
2020-05-22 15:06:17 +02:00
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Routes()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var routes = _actionDescriptorCollectionProvider.ActionDescriptors.Items.ToList();
|
|
|
|
|
if (routes != null && routes.Any())
|
|
|
|
|
{
|
|
|
|
|
return Json(routes);
|
|
|
|
|
}
|
|
|
|
|
return Json(new string [0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal class RouteModel
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public string Template { get; set; }
|
2020-05-21 23:44:43 +02:00
|
|
|
}
|
|
|
|
|
}
|