blublu
This commit is contained in:
@@ -9,6 +9,12 @@ using zero.Core.Validation;
|
||||
|
||||
namespace zero.Core.Api
|
||||
{
|
||||
public interface IApplicationsApi : IApplicationsApi<IApplication>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class ApplicationsApi<T> : BackofficeApi, IApplicationsApi<T> where T : IApplication
|
||||
{
|
||||
IValidator<T> Validator;
|
||||
|
||||
@@ -12,15 +12,6 @@ namespace zero.Core.Entities
|
||||
{
|
||||
public static void AddZeroCoreServices(this IServiceCollection services)
|
||||
{
|
||||
//services.Scan(scan => scan.FromAssemblyOf<IApplication>()
|
||||
// .AddClasses(classes => classes.AssignableTo(typeof(IValidator<>)))
|
||||
// .AsImplementedInterfaces()
|
||||
// //.As(typeof(IValidator<>))
|
||||
// .WithScopedLifetime()
|
||||
//);
|
||||
|
||||
//Assembly[] assemblies = new Assembly[1] { typeof(IApplication).Assembly };
|
||||
|
||||
services.AddAllByInterfaceTransient(typeof(IValidator), typeof(IValidator<>), AppDomain.CurrentDomain.GetAssemblies());
|
||||
|
||||
services.AddTransient<IApplication, Application>();
|
||||
@@ -31,24 +22,6 @@ namespace zero.Core.Entities
|
||||
public static void AddAllByInterfaceTransient<TService, TImplementation>(this IServiceCollection services, Assembly[] assemblies)
|
||||
{
|
||||
services.AddAllByInterfaceTransient(typeof(TService), typeof(TImplementation), assemblies);
|
||||
//Type searchFor = typeof(TService);
|
||||
//string searchForName = nameof(TService); // + (isGeneric ? "`1" : String.Empty);
|
||||
|
||||
//foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
//{
|
||||
// foreach (Type type in assembly.GetExportedTypes())
|
||||
// {
|
||||
// if (searchFor.IsAssignableFrom(type) && type.IsClass)
|
||||
// {
|
||||
// Type service = type.GetInterfaces().FirstOrDefault(x => x.IsInterface && x.Name == searchForName);
|
||||
|
||||
// if (service != null)
|
||||
// {
|
||||
// services.AddTransient(service, type);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace zero.Debug
|
||||
{
|
||||
Include(new ApplicationValidator());
|
||||
|
||||
RuleFor(x => x.Description).NotEmpty();
|
||||
//RuleFor(x => x.Description).NotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ using zero.Core.Identity;
|
||||
namespace zero.Web.Controllers
|
||||
{
|
||||
[ZeroAuthorize(Permissions.Settings.Applications, PermissionsValue.Read)]
|
||||
public class ApplicationsController<T> : BackofficeController where T : IApplication
|
||||
public class ApplicationsController<T> : BackofficeController where T : IApplication, new()
|
||||
{
|
||||
IApplicationsApi<T> Api;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace zero.Web.Controllers
|
||||
/// <summary>
|
||||
/// Get translation by id
|
||||
/// </summary>
|
||||
public IActionResult GetEmpty([FromServices] T app) => JsonEdit(app);
|
||||
public IActionResult GetEmpty() => JsonEdit(new T());
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user