From 96eb4a0d093aa35eb17110434eb02ee362da707f Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Sun, 24 May 2020 14:39:49 +0200 Subject: [PATCH] blublu --- zero.Core/Api/ApplicationsApi.cs | 6 +++++ zero.Core/ServiceCollectionExtensions.cs | 27 ------------------- zero.Debug/MyApplication.cs | 2 +- .../Controllers/ApplicationsController.cs | 4 +-- 4 files changed, 9 insertions(+), 30 deletions(-) diff --git a/zero.Core/Api/ApplicationsApi.cs b/zero.Core/Api/ApplicationsApi.cs index 0cff3168..b7096ed7 100644 --- a/zero.Core/Api/ApplicationsApi.cs +++ b/zero.Core/Api/ApplicationsApi.cs @@ -9,6 +9,12 @@ using zero.Core.Validation; namespace zero.Core.Api { + public interface IApplicationsApi : IApplicationsApi + { + + } + + public class ApplicationsApi : BackofficeApi, IApplicationsApi where T : IApplication { IValidator Validator; diff --git a/zero.Core/ServiceCollectionExtensions.cs b/zero.Core/ServiceCollectionExtensions.cs index aca1f764..643a27b0 100644 --- a/zero.Core/ServiceCollectionExtensions.cs +++ b/zero.Core/ServiceCollectionExtensions.cs @@ -12,15 +12,6 @@ namespace zero.Core.Entities { public static void AddZeroCoreServices(this IServiceCollection services) { - //services.Scan(scan => scan.FromAssemblyOf() - // .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(); @@ -31,24 +22,6 @@ namespace zero.Core.Entities public static void AddAllByInterfaceTransient(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); - // } - // } - // } - //} } diff --git a/zero.Debug/MyApplication.cs b/zero.Debug/MyApplication.cs index b6c8c9f0..1c6b839d 100644 --- a/zero.Debug/MyApplication.cs +++ b/zero.Debug/MyApplication.cs @@ -17,7 +17,7 @@ namespace zero.Debug { Include(new ApplicationValidator()); - RuleFor(x => x.Description).NotEmpty(); + //RuleFor(x => x.Description).NotEmpty(); } } } diff --git a/zero.Web/Controllers/ApplicationsController.cs b/zero.Web/Controllers/ApplicationsController.cs index d0802e60..9fc0e886 100644 --- a/zero.Web/Controllers/ApplicationsController.cs +++ b/zero.Web/Controllers/ApplicationsController.cs @@ -7,7 +7,7 @@ using zero.Core.Identity; namespace zero.Web.Controllers { [ZeroAuthorize(Permissions.Settings.Applications, PermissionsValue.Read)] - public class ApplicationsController : BackofficeController where T : IApplication + public class ApplicationsController : BackofficeController where T : IApplication, new() { IApplicationsApi Api; @@ -20,7 +20,7 @@ namespace zero.Web.Controllers /// /// Get translation by id /// - public IActionResult GetEmpty([FromServices] T app) => JsonEdit(app); + public IActionResult GetEmpty() => JsonEdit(new T()); ///