104 lines
2.3 KiB
C#
104 lines
2.3 KiB
C#
using FluentValidation;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using zero.Core.Api;
|
|
using zero.Core.Entities;
|
|
using zero.Core.Extensions;
|
|
using zero.Core.Utils;
|
|
using zero.Web.Filters;
|
|
|
|
namespace zero.Debug.Controllers
|
|
{
|
|
[ServiceFilter(typeof(ModelStateValidationFilterAttribute))]
|
|
public class TestController : Controller
|
|
{
|
|
private readonly IActionDescriptorCollectionProvider _actionDescriptorCollectionProvider;
|
|
|
|
|
|
public TestController(IActionDescriptorCollectionProvider actionDescriptorCollectionProvider)
|
|
{
|
|
_actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
|
|
}
|
|
|
|
|
|
[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
|
|
});
|
|
}
|
|
|
|
return Json(new
|
|
{
|
|
count = items.Count,
|
|
items
|
|
});
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetTranslations([FromServices] ITranslationsApi api)
|
|
{
|
|
return Json(await api.GetAll());
|
|
}
|
|
|
|
|
|
|
|
[HttpGet]
|
|
public IActionResult Things([FromServices] IValidator<Application> appValidator)
|
|
{
|
|
return Ok();
|
|
}
|
|
|
|
|
|
|
|
[HttpGet]
|
|
public IActionResult Clone([FromServices] IRecycledEntity blueprint)
|
|
{
|
|
IRecycledEntity entity = blueprint.Clone();
|
|
return Json(entity);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
public IActionResult SaveTest([FromBody] IPage model) => Json(model);
|
|
|
|
|
|
|
|
|
|
[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; }
|
|
}
|
|
} |