diff --git a/Demo/AsyncProvider/InMemoryQueryableHandler.cs b/Demo/AsyncProvider/InMemoryQueryableHandler.cs deleted file mode 100644 index 0382f50..0000000 --- a/Demo/AsyncProvider/InMemoryQueryableHandler.cs +++ /dev/null @@ -1,54 +0,0 @@ -using PoweredSoft.Data.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Threading; -using System.Threading.Tasks; - -namespace Demo.AsyncProvider -{ - public class InMemoryQueryableHandler : IAsyncQueryableHandlerService - { - public Task AnyAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) - { - return Task.FromResult(queryable.Any(predicate)); - } - - public Task AnyAsync(IQueryable queryable, CancellationToken cancellationToken = default) - { - return Task.FromResult(queryable.Any()); - } - - public bool CanHandle(IQueryable queryable) - { - var result = queryable is EnumerableQuery; - return result; - } - - public Task CountAsync(IQueryable queryable, CancellationToken cancellationToken = default) - { - return Task.FromResult(queryable.Count()); - } - - public Task FirstOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) - { - return Task.FromResult(queryable.FirstOrDefault()); - } - - public Task FirstOrDefaultAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) - { - return Task.FromResult(queryable.FirstOrDefault(predicate)); - } - - public Task LongCountAsync(IQueryable queryable, CancellationToken cancellationToken = default) - { - return Task.FromResult(queryable.LongCount()); - } - - public Task> ToListAsync(IQueryable queryable, CancellationToken cancellationToken = default) - { - return Task.FromResult(queryable.ToList()); - } - } -} diff --git a/Demo/Commands/CreatePersonCommand.cs b/Demo/Commands/CreatePersonCommand.cs deleted file mode 100644 index 57ce293..0000000 --- a/Demo/Commands/CreatePersonCommand.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Demo.Commands -{ - public class CreatePersonCommand - { - public string FirstName { get; set; } - public string LastName { get; set; } - } -} diff --git a/Demo/Commands/CreatePersonCommandHandler.cs b/Demo/Commands/CreatePersonCommandHandler.cs deleted file mode 100644 index e542a95..0000000 --- a/Demo/Commands/CreatePersonCommandHandler.cs +++ /dev/null @@ -1,14 +0,0 @@ -using PoweredSoft.CQRS.Abstractions; -using System.Threading; -using System.Threading.Tasks; - -namespace Demo.Commands -{ - public class CreatePersonCommandHandler : ICommandHandler - { - public Task HandleAsync(CreatePersonCommand command, CancellationToken cancellationToken = default) - { - return Task.CompletedTask; - } - } -} diff --git a/Demo/Commands/CreatePersonCommandValidator.cs b/Demo/Commands/CreatePersonCommandValidator.cs deleted file mode 100644 index 12498a9..0000000 --- a/Demo/Commands/CreatePersonCommandValidator.cs +++ /dev/null @@ -1,13 +0,0 @@ -using FluentValidation; - -namespace Demo.Commands -{ - public class CreatePersonCommandValidator : AbstractValidator - { - public CreatePersonCommandValidator() - { - RuleFor(t => t.FirstName).NotEmpty(); - RuleFor(t => t.LastName).NotEmpty(); - } - } -} diff --git a/Demo/Commands/EchoCommand.cs b/Demo/Commands/EchoCommand.cs deleted file mode 100644 index 6b201fa..0000000 --- a/Demo/Commands/EchoCommand.cs +++ /dev/null @@ -1,31 +0,0 @@ -using FluentValidation; -using PoweredSoft.CQRS.Abstractions; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace Demo.Commands -{ - public class EchoCommand - { - public string Message { get; set; } - } - - public class EchoCommandValidator : AbstractValidator - { - public EchoCommandValidator() - { - RuleFor(t => t.Message).NotEmpty(); - } - } - - public class EchoCommandHandler : ICommandHandler - { - public Task HandleAsync(EchoCommand command, CancellationToken cancellationToken = default) - { - return Task.FromResult(command.Message); - } - } -} diff --git a/Demo/Demo.csproj b/Demo/Demo.csproj deleted file mode 100644 index 985d1e9..0000000 --- a/Demo/Demo.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - net5.0 - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Demo/DynamicQueries/Contact.cs b/Demo/DynamicQueries/Contact.cs deleted file mode 100644 index ced3f15..0000000 --- a/Demo/DynamicQueries/Contact.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace Demo.DynamicQueries -{ - public class Contact - { - public long Id { get; set; } - public string DisplayName { get; set; } - } - - public class SearchContactParams - { - public string SearchDisplayName { get; set; } - } -} diff --git a/Demo/DynamicQueries/ContactQueryableProvider.cs b/Demo/DynamicQueries/ContactQueryableProvider.cs deleted file mode 100644 index 1947870..0000000 --- a/Demo/DynamicQueries/ContactQueryableProvider.cs +++ /dev/null @@ -1,23 +0,0 @@ -using PoweredSoft.CQRS.DynamicQuery.Abstractions; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace Demo.DynamicQueries -{ - public class ContactQueryableProvider : IQueryableProvider - { - public Task> GetQueryableAsync(object query, CancellationToken cancelllationToken = default) - { - var source = new List - { - new Contact { Id = 1, DisplayName = "David L"}, - new Contact { Id = 2, DisplayName = "John Doe"} - }; - - var ret = source.AsQueryable(); - return Task.FromResult(ret); - } - } -} diff --git a/Demo/DynamicQueries/PersonConvertInterceptor.cs b/Demo/DynamicQueries/PersonConvertInterceptor.cs deleted file mode 100644 index 161235b..0000000 --- a/Demo/DynamicQueries/PersonConvertInterceptor.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Demo.Queries; -using PoweredSoft.DynamicQuery.Core; -using System.Linq; - -namespace Demo.DynamicQueries -{ - public class PersonConvertInterceptor : IQueryConvertInterceptor - { - public PersonModel InterceptResultTo(Person entity) - { - return new PersonModel - { - Id = entity.Id, - FullName = entity.FirstName + " " + entity.LastName - }; - } - } -} diff --git a/Demo/DynamicQueries/PersonModel.cs b/Demo/DynamicQueries/PersonModel.cs deleted file mode 100644 index b51f7dc..0000000 --- a/Demo/DynamicQueries/PersonModel.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace Demo.DynamicQueries -{ - public class PersonModel - { - public long Id { get; set; } - public string FullName { get; set; } - } -} diff --git a/Demo/DynamicQueries/PersonOptimizationInterceptor.cs b/Demo/DynamicQueries/PersonOptimizationInterceptor.cs deleted file mode 100644 index 3163bf0..0000000 --- a/Demo/DynamicQueries/PersonOptimizationInterceptor.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Demo.Queries; -using PoweredSoft.DynamicQuery; -using PoweredSoft.DynamicQuery.Core; -using System.Collections.Generic; - -namespace Demo.DynamicQueries -{ - public class PersonOptimizationInterceptor : IFilterInterceptor, ISortInterceptor - { - public IFilter InterceptFilter(IFilter filter) - { - if (filter is ISimpleFilter simpleFilter) - { - if (simpleFilter.Path.Equals(nameof(PersonModel.FullName), System.StringComparison.InvariantCultureIgnoreCase)) - return new CompositeFilter - { - Type = filter.Type, - And = filter.And, - Filters = new List { - new SimpleFilter - { - Not = simpleFilter.Not, - And = false, - Type = simpleFilter.Type, - Value = simpleFilter.Value, - Path = nameof(Person.FirstName) - }, - new SimpleFilter - { - Not = simpleFilter.Not, - And = false, - Type = simpleFilter.Type, - Value = simpleFilter.Value, - Path = nameof(Person.LastName) - } - } - }; - } - - return filter; - } - - public IEnumerable InterceptSort(IEnumerable sort) - { - foreach(var s in sort) - { - if (s.Path.Equals(nameof(PersonModel.FullName), System.StringComparison.InvariantCultureIgnoreCase)) - yield return new Sort(nameof(Person.LastName), s.Ascending); - else - yield return s; - } - } - } -} diff --git a/Demo/DynamicQueries/PersonQueryableProvider.cs b/Demo/DynamicQueries/PersonQueryableProvider.cs deleted file mode 100644 index f2a9d64..0000000 --- a/Demo/DynamicQueries/PersonQueryableProvider.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Demo.Queries; -using PoweredSoft.CQRS.DynamicQuery.Abstractions; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace Demo.DynamicQueries -{ - public class PersonQueryableProvider : IQueryableProvider - { - private readonly IEnumerable _persons = new List() - { - new Person - { - Id = 1, - FirstName = "David", - LastName = "Lebee" - }, - new Person - { - Id = 2, - FirstName = "John", - LastName = "Doe" - } - }; - - public Task> GetQueryableAsync(object query, CancellationToken cancelllationToken = default) - { - return Task.FromResult(_persons.AsQueryable()); - } - } -} diff --git a/Demo/DynamicQueries/SearchContactParamsService.cs b/Demo/DynamicQueries/SearchContactParamsService.cs deleted file mode 100644 index 0d4e999..0000000 --- a/Demo/DynamicQueries/SearchContactParamsService.cs +++ /dev/null @@ -1,19 +0,0 @@ -using PoweredSoft.CQRS.DynamicQuery.Abstractions; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace Demo.DynamicQueries -{ - public class SearchContactParamsService : IAlterQueryableService - { - public Task> AlterQueryableAsync(IQueryable query, IDynamicQueryParams dynamicQuery, CancellationToken cancellationToken = default) - { - var safe = dynamicQuery.GetParams()?.SearchDisplayName; - if (!string.IsNullOrEmpty(safe)) - return Task.FromResult(query.Where(t => t.DisplayName.Contains(safe))); - - return Task.FromResult(query); - } - } -} diff --git a/Demo/Program.cs b/Demo/Program.cs deleted file mode 100644 index 7e5335f..0000000 --- a/Demo/Program.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Demo -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } -} diff --git a/Demo/Properties/launchSettings.json b/Demo/Properties/launchSettings.json deleted file mode 100644 index 948de0d..0000000 --- a/Demo/Properties/launchSettings.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:52483", - "sslPort": 44343 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": false, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Demo": { - "commandName": "Project", - "launchBrowser": false, - "applicationUrl": "https://localhost:5001;http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/Demo/Queries/ListPersonQuery.cs b/Demo/Queries/ListPersonQuery.cs deleted file mode 100644 index 013521b..0000000 --- a/Demo/Queries/ListPersonQuery.cs +++ /dev/null @@ -1,32 +0,0 @@ -using PoweredSoft.CQRS.Abstractions; -using PoweredSoft.CQRS.DynamicQuery.Abstractions; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace Demo.Queries -{ - public class OnePersonQuery - { - public long PersonId { get; set; } - } - - public class OnePersonQueryHandler : IQueryHandler - { - private readonly IQueryableProvider provider; - - public OnePersonQueryHandler(IQueryableProvider provider) - { - this.provider = provider; - } - - public async Task HandleAsync(OnePersonQuery query, CancellationToken cancellationToken = default) - { - var _ = await provider.GetQueryableAsync(query, cancellationToken); - var ret = _.First(t => t.Id == query.PersonId); - return ret; - } - } -} diff --git a/Demo/Queries/OnePerson.cs b/Demo/Queries/OnePerson.cs deleted file mode 100644 index 4ae19ca..0000000 --- a/Demo/Queries/OnePerson.cs +++ /dev/null @@ -1,39 +0,0 @@ -using PoweredSoft.CQRS.Abstractions; -using PoweredSoft.CQRS.DynamicQuery.Abstractions; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace Demo.Queries -{ - public class ListPersonQuery - { - public string Search { get; set; } - } - - public class ListPersonQueryHandler : IQueryHandler> - { - private readonly IQueryableProvider provider; - - public ListPersonQueryHandler(IQueryableProvider provider) - { - this.provider = provider; - } - - public async Task> HandleAsync(ListPersonQuery query, CancellationToken cancellationToken = default) - { - var _ = await provider.GetQueryableAsync(query, cancellationToken); - - if (query.Search != null) - _ = _ - .Where(t => t.FirstName.Contains(query.Search, StringComparison.InvariantCultureIgnoreCase) || - t.LastName.Contains(query.Search, StringComparison.InvariantCultureIgnoreCase)); - - - var ret = _.ToList(); - return ret; - } - } -} diff --git a/Demo/Queries/PersonQuery.cs b/Demo/Queries/PersonQuery.cs deleted file mode 100644 index 71153d8..0000000 --- a/Demo/Queries/PersonQuery.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Collections.Generic; - -namespace Demo.Queries -{ - public class Person - { - public long Id { get; set; } - public string FirstName { get; set; } - public string LastName { get; set; } - } - - public class PersonQuery - { - public string Search { get; set; } - } -} diff --git a/Demo/Queries/PersonQueryHandler.cs b/Demo/Queries/PersonQueryHandler.cs deleted file mode 100644 index 692311a..0000000 --- a/Demo/Queries/PersonQueryHandler.cs +++ /dev/null @@ -1,29 +0,0 @@ -using PoweredSoft.CQRS.Abstractions; -using PoweredSoft.CQRS.DynamicQuery.Abstractions; -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace Demo.Queries -{ - public class PersonQueryHandler : IQueryHandler> - { - private readonly IQueryableProvider queryableProvider; - - public PersonQueryHandler(IQueryableProvider queryableProvider) - { - this.queryableProvider = queryableProvider; - } - - public async Task> HandleAsync(PersonQuery query, CancellationToken cancellationToken = default) - { - var ret = await queryableProvider.GetQueryableAsync(query); - - if (query != null && !string.IsNullOrEmpty(query.Search)) - ret = ret.Where(t => t.FirstName.Contains(query.Search) || t.LastName.Contains(query.Search)); - - return ret; - } - } -} diff --git a/Demo/Security/CommandAndQueryAuthorizationService.cs b/Demo/Security/CommandAndQueryAuthorizationService.cs deleted file mode 100644 index bc83625..0000000 --- a/Demo/Security/CommandAndQueryAuthorizationService.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.AspNetCore.Http; -using PoweredSoft.CQRS.Abstractions.Security; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace Demo.Security -{ - public class CommandAndQueryAuthorizationService : IQueryAuthorizationService, ICommandAuthorizationService - { - private readonly IHttpContextAccessor httpContextAccessor; - - public CommandAndQueryAuthorizationService(IHttpContextAccessor httpContextAccessor) - { - this.httpContextAccessor = httpContextAccessor; - } - - public Task IsAllowedAsync(Type queryOrCommandType, CancellationToken cancellationToken = default) - { - var authResult = httpContextAccessor.HttpContext.Request.Query["auth-result"].FirstOrDefault(); - if (authResult == "Unauthorized") - return Task.FromResult(AuthorizationResult.Unauthorized); - else if (authResult == "Forbidden") - return Task.FromResult(AuthorizationResult.Forbidden); - - return Task.FromResult(AuthorizationResult.Allowed); - } - } -} diff --git a/Demo/Startup.cs b/Demo/Startup.cs deleted file mode 100644 index fc42e60..0000000 --- a/Demo/Startup.cs +++ /dev/null @@ -1,145 +0,0 @@ -using Demo.AsyncProvider; -using Demo.Commands; -using Demo.DynamicQueries; -using Demo.Queries; -using FluentValidation; -using FluentValidation.AspNetCore; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using PoweredSoft.CQRS; -using PoweredSoft.CQRS.Abstractions; -using PoweredSoft.CQRS.AspNetCore.Mvc; -using PoweredSoft.CQRS.DynamicQuery; -using PoweredSoft.CQRS.DynamicQuery.Abstractions; -using PoweredSoft.CQRS.DynamicQuery.AspNetCore; -using PoweredSoft.CQRS.GraphQL.FluentValidation; -using PoweredSoft.CQRS.GraphQL.HotChocolate; -using PoweredSoft.Data; -using PoweredSoft.Data.Core; -using PoweredSoft.DynamicQuery; -using System.Linq; -using PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery; -using PoweredSoft.CQRS.Abstractions.Security; -using Demo.Security; -using PoweredSoft.CQRS.FluentValidation; -using Microsoft.AspNetCore.OData; -using System.Collections.Generic; - -namespace Demo -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - AddQueries(services); - AddDynamicQueries(services); - AddCommands(services); - - services.AddHttpContextAccessor(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddPoweredSoftDataServices(); - services.AddPoweredSoftDynamicQuery(); - - services.AddPoweredSoftCQRS(); - - services - .AddControllers() - .AddPoweredSoftQueries() - .AddPoweredSoftCommands() - .AddPoweredSoftDynamicQueries() - .AddFluentValidation(); - - services - .AddGraphQLServer() - .AddProjections() - .AddQueryType(d => d.Name("Query")) - .AddPoweredSoftQueries() - .AddPoweredSoftDynamicQueries() - .AddMutationType(d => d.Name("Mutation")) - .AddPoweredSoftMutations(); - - services.AddPoweredSoftGraphQLFluentValidation(); - - services.AddSwaggerGen(); - services.AddCors(); - } - - private void AddDynamicQueries(IServiceCollection services) - { - services.AddTransient, ContactQueryableProvider>(); - services.AddDynamicQuery(); - services.AddDynamicQueryWithParams(name: "SearchContacts") - .AddAlterQueryableWithParams(); - - services - .AddTransient, PersonQueryableProvider>() - .AddDynamicQuery(name: "People") - .AddDynamicQueryInterceptors(); - } - - private void AddCommands(IServiceCollection services) - { - services.AddCommand(); - services.AddTransient, CreatePersonCommandValidator>(); - - /* OLD WAY STILL VALID - services.AddCommand(); - services.AddTransient, EchoCommandValidator>();*/ - - // new way :) with PoweredSoft.CQRS.FluentValidation package. - services.AddCommandWithValidator(); - } - - private void AddQueries(IServiceCollection services) - { - services.AddQuery, PersonQueryHandler>(); - services.AddQuery(); - services.AddQuery, ListPersonQueryHandler>(); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseHttpsRedirection(); - - app.UseCors(o => o.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); - - app.UseRouting(); - - app.UseAuthorization(); - - app.UseSwagger(); - - // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), - // specifying the Swagger JSON endpoint. - app.UseSwaggerUI(c => - { - c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); - }); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - endpoints.MapGraphQL(); - }); - } - } -} diff --git a/Demo/appsettings.Development.json b/Demo/appsettings.Development.json deleted file mode 100644 index 8983e0f..0000000 --- a/Demo/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/Demo/appsettings.json b/Demo/appsettings.json deleted file mode 100644 index d9d9a9b..0000000 --- a/Demo/appsettings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*" -} diff --git a/PoweredSoft.CQRS.Abstractions/Attributes/CommandNameAttribute.cs b/PoweredSoft.CQRS.Abstractions/Attributes/CommandNameAttribute.cs index 30b588c..04880c4 100644 --- a/PoweredSoft.CQRS.Abstractions/Attributes/CommandNameAttribute.cs +++ b/PoweredSoft.CQRS.Abstractions/Attributes/CommandNameAttribute.cs @@ -1,10 +1,8 @@ using System; -using System.Collections.Generic; -using System.Text; namespace PoweredSoft.CQRS.Abstractions.Attributes { - [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] public class CommandNameAttribute : Attribute { public CommandNameAttribute(string name) diff --git a/PoweredSoft.CQRS.Abstractions/Attributes/QueryNameAttribute.cs b/PoweredSoft.CQRS.Abstractions/Attributes/QueryNameAttribute.cs index d584f48..329b996 100644 --- a/PoweredSoft.CQRS.Abstractions/Attributes/QueryNameAttribute.cs +++ b/PoweredSoft.CQRS.Abstractions/Attributes/QueryNameAttribute.cs @@ -2,7 +2,7 @@ namespace PoweredSoft.CQRS.Abstractions.Attributes { - [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] public class QueryNameAttribute : Attribute { public QueryNameAttribute(string name) diff --git a/PoweredSoft.CQRS.Abstractions/Discovery/IQueryDiscovery.cs b/PoweredSoft.CQRS.Abstractions/Discovery/IQueryDiscovery.cs index f9c1915..6e335fb 100644 --- a/PoweredSoft.CQRS.Abstractions/Discovery/IQueryDiscovery.cs +++ b/PoweredSoft.CQRS.Abstractions/Discovery/IQueryDiscovery.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; namespace PoweredSoft.CQRS.Abstractions.Discovery { diff --git a/PoweredSoft.CQRS.Abstractions/Discovery/IQueryMeta.cs b/PoweredSoft.CQRS.Abstractions/Discovery/IQueryMeta.cs index cb10539..e272317 100644 --- a/PoweredSoft.CQRS.Abstractions/Discovery/IQueryMeta.cs +++ b/PoweredSoft.CQRS.Abstractions/Discovery/IQueryMeta.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; namespace PoweredSoft.CQRS.Abstractions.Discovery { diff --git a/PoweredSoft.CQRS.Abstractions/ICommandHandler.cs b/PoweredSoft.CQRS.Abstractions/ICommandHandler.cs index 3afc5f4..e36dfa1 100644 --- a/PoweredSoft.CQRS.Abstractions/ICommandHandler.cs +++ b/PoweredSoft.CQRS.Abstractions/ICommandHandler.cs @@ -1,16 +1,15 @@ -using System; -using System.Threading; +using System.Threading; using System.Threading.Tasks; namespace PoweredSoft.CQRS.Abstractions { - public interface ICommandHandler + public interface ICommandHandler where TCommand : class { Task HandleAsync(TCommand command, CancellationToken cancellationToken = default); } - public interface ICommandHandler + public interface ICommandHandler where TCommand : class { Task HandleAsync(TCommand command, CancellationToken cancellationToken = default); diff --git a/PoweredSoft.CQRS.Abstractions/IQueryHandler.cs b/PoweredSoft.CQRS.Abstractions/IQueryHandler.cs index 9061efc..a3116b3 100644 --- a/PoweredSoft.CQRS.Abstractions/IQueryHandler.cs +++ b/PoweredSoft.CQRS.Abstractions/IQueryHandler.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; namespace PoweredSoft.CQRS.Abstractions { - public interface IQueryHandler + public interface IQueryHandler where TQuery : class { Task HandleAsync(TQuery query, CancellationToken cancellationToken = default); diff --git a/PoweredSoft.CQRS.Abstractions/PoweredSoft.CQRS.Abstractions.csproj b/PoweredSoft.CQRS.Abstractions/PoweredSoft.CQRS.Abstractions.csproj index 58b0de0..63c96a1 100644 --- a/PoweredSoft.CQRS.Abstractions/PoweredSoft.CQRS.Abstractions.csproj +++ b/PoweredSoft.CQRS.Abstractions/PoweredSoft.CQRS.Abstractions.csproj @@ -1,13 +1,13 @@  - - netstandard2.0 + netstandard2.1 Powered Softwares Inc. https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro PoweredSoft PoweredSoft Team + - + diff --git a/PoweredSoft.CQRS.Abstractions/ServiceCollectionExtensions.cs b/PoweredSoft.CQRS.Abstractions/ServiceCollectionExtensions.cs index d54e06a..ee920d6 100644 --- a/PoweredSoft.CQRS.Abstractions/ServiceCollectionExtensions.cs +++ b/PoweredSoft.CQRS.Abstractions/ServiceCollectionExtensions.cs @@ -1,8 +1,5 @@ using Microsoft.Extensions.DependencyInjection; using PoweredSoft.CQRS.Abstractions.Discovery; -using System; -using System.Collections.Generic; -using System.Text; namespace PoweredSoft.CQRS.Abstractions { diff --git a/PoweredSoft.CQRS.AspNetCore.Abstractions/Attributes/CommandControllerIgnoreAttribute.cs b/PoweredSoft.CQRS.AspNetCore.Abstractions/Attributes/CommandControllerIgnoreAttribute.cs index 69071a8..10c1706 100644 --- a/PoweredSoft.CQRS.AspNetCore.Abstractions/Attributes/CommandControllerIgnoreAttribute.cs +++ b/PoweredSoft.CQRS.AspNetCore.Abstractions/Attributes/CommandControllerIgnoreAttribute.cs @@ -2,7 +2,7 @@ namespace PoweredSoft.CQRS.AspNetCore.Abstractions.Attributes { - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] public class CommandControllerIgnoreAttribute : Attribute { } diff --git a/PoweredSoft.CQRS.AspNetCore.Abstractions/Attributes/QueryControllerIgnoreAttribute.cs b/PoweredSoft.CQRS.AspNetCore.Abstractions/Attributes/QueryControllerIgnoreAttribute.cs index 46b59cf..8cc10ff 100644 --- a/PoweredSoft.CQRS.AspNetCore.Abstractions/Attributes/QueryControllerIgnoreAttribute.cs +++ b/PoweredSoft.CQRS.AspNetCore.Abstractions/Attributes/QueryControllerIgnoreAttribute.cs @@ -1,10 +1,8 @@ using System; -using System.Collections.Generic; -using System.Text; namespace PoweredSoft.CQRS.AspNetCore.Abstractions.Attributes { - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] + [AttributeUsage(AttributeTargets.Class, Inherited = false)] public class QueryControllerIgnoreAttribute : Attribute { } diff --git a/PoweredSoft.CQRS.AspNetCore.Abstractions/PoweredSoft.CQRS.AspNetCore.Abstractions.csproj b/PoweredSoft.CQRS.AspNetCore.Abstractions/PoweredSoft.CQRS.AspNetCore.Abstractions.csproj index 892921b..88e46c2 100644 --- a/PoweredSoft.CQRS.AspNetCore.Abstractions/PoweredSoft.CQRS.AspNetCore.Abstractions.csproj +++ b/PoweredSoft.CQRS.AspNetCore.Abstractions/PoweredSoft.CQRS.AspNetCore.Abstractions.csproj @@ -1,11 +1,9 @@ - - netstandard2.0 + netstandard2.1 Powered Softwares Inc. https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro PoweredSoft PoweredSoft Team - diff --git a/PoweredSoft.CQRS.AspNetCore/Mvc/CommandController.cs b/PoweredSoft.CQRS.AspNetCore/Mvc/CommandController.cs index 2cabc11..e48bba9 100644 --- a/PoweredSoft.CQRS.AspNetCore/Mvc/CommandController.cs +++ b/PoweredSoft.CQRS.AspNetCore/Mvc/CommandController.cs @@ -1,9 +1,6 @@ -using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; using PoweredSoft.CQRS.Abstractions; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; namespace PoweredSoft.CQRS.AspNetCore.Mvc { diff --git a/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerAsyncAuthorizationFilter.cs b/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerAsyncAuthorizationFilter.cs index 7fa7934..332c755 100644 --- a/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerAsyncAuthorizationFilter.cs +++ b/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerAsyncAuthorizationFilter.cs @@ -11,16 +11,16 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc { public class CommandControllerAsyncAuthorizationFilter : IAsyncAuthorizationFilter { - private readonly ICommandAuthorizationService _authorizationService; + private readonly ICommandAuthorizationService authorizationService; public CommandControllerAsyncAuthorizationFilter(IServiceProvider serviceProvider) { - _authorizationService = serviceProvider.GetService(); + authorizationService = serviceProvider.GetService(); } public async Task OnAuthorizationAsync(AuthorizationFilterContext context) { - if (_authorizationService == null) + if (authorizationService == null) return; var action = context.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor; @@ -34,7 +34,7 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc else commandType = action.ControllerTypeInfo.GenericTypeArguments.First(); - var ar = await _authorizationService.IsAllowedAsync(commandType); + var ar = await authorizationService.IsAllowedAsync(commandType); if (ar == AuthorizationResult.Forbidden) context.Result = new StatusCodeResult(403); else if(ar == AuthorizationResult.Unauthorized) diff --git a/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerConvention.cs b/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerConvention.cs index eb5c5e7..deacea3 100644 --- a/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerConvention.cs +++ b/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerConvention.cs @@ -16,13 +16,19 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc public void Apply(ControllerModel controller) { - if (controller.ControllerType.IsGenericType && controller.ControllerType.Name.Contains("CommandController") && controller.ControllerType.Assembly == typeof(CommandControllerConvention).Assembly) - { - var genericType = controller.ControllerType.GenericTypeArguments[0]; - var commandDiscovery = this.serviceProvider.GetRequiredService(); - var command = commandDiscovery.FindCommand(genericType); - controller.ControllerName = command.LowerCamelCaseName; - } + if (!controller.ControllerType.IsGenericType) + return; + + if (!controller.ControllerType.Name.Contains("CommandController")) + return; + + if (controller.ControllerType.Assembly != typeof(CommandControllerConvention).Assembly) + return; + + var genericType = controller.ControllerType.GenericTypeArguments[0]; + var commandDiscovery = this.serviceProvider.GetRequiredService(); + var command = commandDiscovery.FindCommand(genericType); + controller.ControllerName = command.LowerCamelCaseName; } } } diff --git a/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerFeatureProvider.cs b/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerFeatureProvider.cs index 221a0f1..16207fe 100644 --- a/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerFeatureProvider.cs +++ b/PoweredSoft.CQRS.AspNetCore/Mvc/CommandControllerFeatureProvider.cs @@ -1,12 +1,10 @@ -using Microsoft.AspNetCore.Mvc.ApplicationParts; +using System.Collections.Generic; +using System.Reflection; +using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.Extensions.DependencyInjection; using PoweredSoft.CQRS.Abstractions.Discovery; using PoweredSoft.CQRS.AspNetCore.Abstractions.Attributes; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; namespace PoweredSoft.CQRS.AspNetCore.Mvc { diff --git a/PoweredSoft.CQRS.AspNetCore/Mvc/QueryController.cs b/PoweredSoft.CQRS.AspNetCore/Mvc/QueryController.cs index 2302315..038496d 100644 --- a/PoweredSoft.CQRS.AspNetCore/Mvc/QueryController.cs +++ b/PoweredSoft.CQRS.AspNetCore/Mvc/QueryController.cs @@ -1,9 +1,6 @@ -using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; using PoweredSoft.CQRS.Abstractions; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; namespace PoweredSoft.CQRS.AspNetCore.Mvc { diff --git a/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerAsyncAuthorizationFilter.cs b/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerAsyncAuthorizationFilter.cs index 1caaa5c..c032390 100644 --- a/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerAsyncAuthorizationFilter.cs +++ b/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerAsyncAuthorizationFilter.cs @@ -11,16 +11,16 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc { public class QueryControllerAsyncAuthorizationFilter : IAsyncAuthorizationFilter { - private readonly IQueryAuthorizationService _authorizationService; + private readonly IQueryAuthorizationService authorizationService; public QueryControllerAsyncAuthorizationFilter(IServiceProvider serviceProvider) { - _authorizationService = serviceProvider.GetService(); + authorizationService = serviceProvider.GetService(); } public async Task OnAuthorizationAsync(AuthorizationFilterContext context) { - if (_authorizationService == null) + if (authorizationService == null) return; var action = context.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor; @@ -34,7 +34,7 @@ namespace PoweredSoft.CQRS.AspNetCore.Mvc else queryType = action.ControllerTypeInfo.GenericTypeArguments.First(); - var ar = await _authorizationService.IsAllowedAsync(queryType); + var ar = await authorizationService.IsAllowedAsync(queryType); if (ar == AuthorizationResult.Forbidden) context.Result = new StatusCodeResult(403); else if (ar == AuthorizationResult.Unauthorized) diff --git a/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerFeatureProvider.cs b/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerFeatureProvider.cs index b1d9f69..e15065b 100644 --- a/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerFeatureProvider.cs +++ b/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerFeatureProvider.cs @@ -1,12 +1,10 @@ -using Microsoft.AspNetCore.Mvc.ApplicationParts; +using System.Collections.Generic; +using System.Reflection; +using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.Extensions.DependencyInjection; using PoweredSoft.CQRS.Abstractions.Discovery; using PoweredSoft.CQRS.AspNetCore.Abstractions.Attributes; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; namespace PoweredSoft.CQRS.AspNetCore.Mvc { diff --git a/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerOptions.cs b/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerOptions.cs index 0474580..4ed12ea 100644 --- a/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerOptions.cs +++ b/PoweredSoft.CQRS.AspNetCore/Mvc/QueryControllerOptions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace PoweredSoft.CQRS.AspNetCore.Mvc +namespace PoweredSoft.CQRS.AspNetCore.Mvc { public class QueryControllerOptions { diff --git a/PoweredSoft.CQRS.AspNetCore/PoweredSoft.CQRS.AspNetCore.csproj b/PoweredSoft.CQRS.AspNetCore/PoweredSoft.CQRS.AspNetCore.csproj index 4955297..85de34e 100644 --- a/PoweredSoft.CQRS.AspNetCore/PoweredSoft.CQRS.AspNetCore.csproj +++ b/PoweredSoft.CQRS.AspNetCore/PoweredSoft.CQRS.AspNetCore.csproj @@ -1,11 +1,12 @@  - netcoreapp3.1;net5.0 + net8.0 Powered Softwares Inc. https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro PoweredSoft PoweredSoft Team + true diff --git a/PoweredSoft.CQRS.DynamicQuery.Abstractions/IAlterQueryableService.cs b/PoweredSoft.CQRS.DynamicQuery.Abstractions/IAlterQueryableService.cs index 11c6d2f..06279ee 100644 --- a/PoweredSoft.CQRS.DynamicQuery.Abstractions/IAlterQueryableService.cs +++ b/PoweredSoft.CQRS.DynamicQuery.Abstractions/IAlterQueryableService.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQuery.cs b/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQuery.cs index 0780e60..923ccdf 100644 --- a/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQuery.cs +++ b/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQuery.cs @@ -1,7 +1,5 @@ -using PoweredSoft.DynamicQuery.Core; -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; +using PoweredSoft.DynamicQuery.Core; namespace PoweredSoft.CQRS.DynamicQuery.Abstractions { @@ -12,7 +10,7 @@ namespace PoweredSoft.CQRS.DynamicQuery.Abstractions } - public interface IDynamicQuery : IDynamicQuery, IDynamicQueryParams + public interface IDynamicQuery : IDynamicQuery, IDynamicQueryParams where TSource : class where TDestination : class where TParams : class @@ -21,7 +19,6 @@ namespace PoweredSoft.CQRS.DynamicQuery.Abstractions } public interface IDynamicQuery - { List GetFilters(); List GetGroups(); diff --git a/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQueryInterceptorProvider.cs b/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQueryInterceptorProvider.cs index 28cb8ae..ee6e405 100644 --- a/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQueryInterceptorProvider.cs +++ b/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQueryInterceptorProvider.cs @@ -1,7 +1,5 @@ -using PoweredSoft.DynamicQuery.Core; -using System; +using System; using System.Collections.Generic; -using System.Text; namespace PoweredSoft.CQRS.DynamicQuery.Abstractions { diff --git a/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQueryParams.cs b/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQueryParams.cs index 099c2f8..51f877f 100644 --- a/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQueryParams.cs +++ b/PoweredSoft.CQRS.DynamicQuery.Abstractions/IDynamicQueryParams.cs @@ -1,6 +1,6 @@ namespace PoweredSoft.CQRS.DynamicQuery.Abstractions { - public interface IDynamicQueryParams + public interface IDynamicQueryParams where TParams : class { TParams GetParams(); diff --git a/PoweredSoft.CQRS.DynamicQuery.Abstractions/IQueryableProvider.cs b/PoweredSoft.CQRS.DynamicQuery.Abstractions/IQueryableProvider.cs index e4e2d94..6a9f566 100644 --- a/PoweredSoft.CQRS.DynamicQuery.Abstractions/IQueryableProvider.cs +++ b/PoweredSoft.CQRS.DynamicQuery.Abstractions/IQueryableProvider.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -9,6 +6,6 @@ namespace PoweredSoft.CQRS.DynamicQuery.Abstractions { public interface IQueryableProvider { - Task> GetQueryableAsync(object query, CancellationToken cancelllationToken = default); + Task> GetQueryableAsync(object query, CancellationToken cancellationToken = default); } } diff --git a/PoweredSoft.CQRS.DynamicQuery.Abstractions/PoweredSoft.CQRS.DynamicQuery.Abstractions.csproj b/PoweredSoft.CQRS.DynamicQuery.Abstractions/PoweredSoft.CQRS.DynamicQuery.Abstractions.csproj index fe8d1ce..3f0fa63 100644 --- a/PoweredSoft.CQRS.DynamicQuery.Abstractions/PoweredSoft.CQRS.DynamicQuery.Abstractions.csproj +++ b/PoweredSoft.CQRS.DynamicQuery.Abstractions/PoweredSoft.CQRS.DynamicQuery.Abstractions.csproj @@ -1,7 +1,6 @@  - - netstandard2.0 + netstandard2.1 Powered Softwares Inc. https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro PoweredSoft @@ -11,5 +10,4 @@ - diff --git a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/DynamicQuery.cs b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/DynamicQuery.cs index 85c9838..a9df635 100644 --- a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/DynamicQuery.cs +++ b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/DynamicQuery.cs @@ -1,10 +1,8 @@ -using PoweredSoft.CQRS.DynamicQuery.Abstractions; +using System.Collections.Generic; +using System.Linq; +using PoweredSoft.CQRS.DynamicQuery.Abstractions; using PoweredSoft.DynamicQuery; using PoweredSoft.DynamicQuery.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore { diff --git a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/DynamicQueryFilter.cs b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/DynamicQueryFilter.cs index 6a83262..a48adc0 100644 --- a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/DynamicQueryFilter.cs +++ b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/DynamicQueryFilter.cs @@ -1,10 +1,10 @@ -using Microsoft.AspNetCore.Mvc; -using PoweredSoft.DynamicQuery; -using PoweredSoft.DynamicQuery.Core; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text.Json; +using Microsoft.AspNetCore.Mvc; +using PoweredSoft.DynamicQuery; +using PoweredSoft.DynamicQuery.Core; namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore { @@ -49,18 +49,29 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore object value = Value; if (Value is JsonElement jsonElement) { - if (jsonElement.ValueKind == JsonValueKind.String) - value = jsonElement.ToString(); - else if (jsonElement.ValueKind == JsonValueKind.Number && jsonElement.TryGetInt64(out var l)) - value = l; - else if (jsonElement.ValueKind == JsonValueKind.True) - value = true; - else if (jsonElement.ValueKind == JsonValueKind.False) - value = false; - else if (jsonElement.ValueKind == JsonValueKind.Array) - throw new System.Exception("TODO"); - else - value = null; + switch (jsonElement.ValueKind) + { + case JsonValueKind.String: + value = jsonElement.ToString(); + break; + case JsonValueKind.Number: + if (jsonElement.ToString().Contains('.')) + value = jsonElement.GetDecimal(); + else if (jsonElement.TryGetInt64(out var convertedValue)) + value = convertedValue; + break; + case JsonValueKind.True: + value = true; + break; + case JsonValueKind.False: + value = false; + break; + // TODO: Array support + default: + value = null; + break; + } + } var simpleFilter = new SimpleFilter diff --git a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryController.cs b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryController.cs index 12f9d37..cf142e3 100644 --- a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryController.cs +++ b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryController.cs @@ -1,23 +1,21 @@ -using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using PoweredSoft.CQRS.Abstractions; using PoweredSoft.CQRS.AspNetCore.Mvc; using PoweredSoft.CQRS.DynamicQuery.Abstractions; using PoweredSoft.DynamicQuery.Core; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc { [ApiController, Route("api/query/[controller]")] - public class DynamicQueryController : Controller + public class DynamicQueryController : Controller where TSource : class where TDestination : class { [HttpPost, QueryControllerAuthorization] public async Task> HandleAsync( [FromBody] DynamicQuery query, - [FromServices]PoweredSoft.CQRS.Abstractions.IQueryHandler, IQueryExecutionResult> queryHandler + [FromServices]IQueryHandler, IQueryExecutionResult> queryHandler ) { var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted); @@ -27,7 +25,7 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc [HttpGet, QueryControllerAuthorization] public async Task> HandleGetAsync( [FromQuery] DynamicQuery query, - [FromServices] PoweredSoft.CQRS.Abstractions.IQueryHandler, IQueryExecutionResult> queryHandler + [FromServices] IQueryHandler, IQueryExecutionResult> queryHandler ) { var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted); @@ -36,7 +34,7 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc } [ApiController, Route("api/query/[controller]")] - public class DynamicQueryController : Controller + public class DynamicQueryController : Controller where TSource : class where TDestination : class where TParams : class @@ -44,7 +42,7 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc [HttpPost, QueryControllerAuthorization] public async Task> HandleAsync( [FromBody] DynamicQuery query, - [FromServices] PoweredSoft.CQRS.Abstractions.IQueryHandler, IQueryExecutionResult> queryHandler + [FromServices] IQueryHandler, IQueryExecutionResult> queryHandler ) { var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted); @@ -54,7 +52,7 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc [HttpGet, QueryControllerAuthorization] public async Task> HandleGetAsync( [FromQuery] DynamicQuery query, - [FromServices] PoweredSoft.CQRS.Abstractions.IQueryHandler, IQueryExecutionResult> queryHandler + [FromServices] IQueryHandler, IQueryExecutionResult> queryHandler ) { var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted); diff --git a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerConvention.cs b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerConvention.cs index 2f90166..841a22f 100644 --- a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerConvention.cs +++ b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerConvention.cs @@ -1,9 +1,7 @@ -using Microsoft.AspNetCore.Mvc.ApplicationModels; +using System; +using Microsoft.AspNetCore.Mvc.ApplicationModels; using Microsoft.Extensions.DependencyInjection; using PoweredSoft.CQRS.Abstractions.Discovery; -using System; -using System.Collections.Generic; -using System.Text; namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc { diff --git a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerFeatureProvider.cs b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerFeatureProvider.cs index 9e9fe94..ff5f24a 100644 --- a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerFeatureProvider.cs +++ b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerFeatureProvider.cs @@ -1,13 +1,11 @@ -using Microsoft.AspNetCore.Mvc.ApplicationParts; +using System.Collections.Generic; +using System.Reflection; +using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.Extensions.DependencyInjection; using PoweredSoft.CQRS.Abstractions.Discovery; using PoweredSoft.CQRS.AspNetCore.Abstractions.Attributes; using PoweredSoft.CQRS.DynamicQuery.Discover; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc { @@ -36,13 +34,13 @@ namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc { if (dynamicQueryMeta.ParamsType == null) { - var controllerType = typeof(DynamicQueryController<,,>).MakeGenericType(f.QueryType, dynamicQueryMeta.SourceType, dynamicQueryMeta.DestinationType); + var controllerType = typeof(DynamicQueryController<,>).MakeGenericType(f.QueryType, dynamicQueryMeta.SourceType, dynamicQueryMeta.DestinationType); var controllerTypeInfo = controllerType.GetTypeInfo(); feature.Controllers.Add(controllerTypeInfo); } else { - var controllerType = typeof(DynamicQueryController<,,,>).MakeGenericType(f.QueryType, dynamicQueryMeta.SourceType, dynamicQueryMeta.DestinationType, dynamicQueryMeta.ParamsType); + var controllerType = typeof(DynamicQueryController<,,>).MakeGenericType(f.QueryType, dynamicQueryMeta.SourceType, dynamicQueryMeta.DestinationType, dynamicQueryMeta.ParamsType); var controllerTypeInfo = controllerType.GetTypeInfo(); feature.Controllers.Add(controllerTypeInfo); } diff --git a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerOptions.cs b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerOptions.cs index 30840b5..35164b9 100644 --- a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerOptions.cs +++ b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/Mvc/DynamicQueryControllerOptions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc +namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc { public class DynamicQueryControllerOptions { diff --git a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/MvcBuilderExtensions.cs b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/MvcBuilderExtensions.cs index 4600ca8..bd809dd 100644 --- a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/MvcBuilderExtensions.cs +++ b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/MvcBuilderExtensions.cs @@ -1,11 +1,6 @@ -using Microsoft.Extensions.DependencyInjection; -using PoweredSoft.CQRS.DynamicQuery.Abstractions; +using System; +using Microsoft.Extensions.DependencyInjection; using PoweredSoft.CQRS.DynamicQuery.AspNetCore.Mvc; -using PoweredSoft.DynamicQuery.Core; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; namespace PoweredSoft.CQRS.DynamicQuery.AspNetCore { diff --git a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/PoweredSoft.CQRS.DynamicQuery.AspNetCore.csproj b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/PoweredSoft.CQRS.DynamicQuery.AspNetCore.csproj index 2b7a65e..239a49c 100644 --- a/PoweredSoft.CQRS.DynamicQuery.AspNetCore/PoweredSoft.CQRS.DynamicQuery.AspNetCore.csproj +++ b/PoweredSoft.CQRS.DynamicQuery.AspNetCore/PoweredSoft.CQRS.DynamicQuery.AspNetCore.csproj @@ -1,11 +1,11 @@ - - netcoreapp3.1;net5.0 + net8.0 Powered Softwares Inc. https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro PoweredSoft PoweredSoft Team + true @@ -19,5 +19,4 @@ - diff --git a/PoweredSoft.CQRS.DynamicQuery/Discover/DynamicQueryMeta.cs b/PoweredSoft.CQRS.DynamicQuery/Discover/DynamicQueryMeta.cs index a693c60..de9034a 100644 --- a/PoweredSoft.CQRS.DynamicQuery/Discover/DynamicQueryMeta.cs +++ b/PoweredSoft.CQRS.DynamicQuery/Discover/DynamicQueryMeta.cs @@ -1,8 +1,6 @@ -using PoweredSoft.CQRS.Abstractions.Discovery; -using PoweredSoft.CQRS.Discovery; -using System; -using System.Collections.Generic; -using System.Text; +using System; +using Pluralize.NET; +using PoweredSoft.CQRS.Abstractions.Discovery; namespace PoweredSoft.CQRS.DynamicQuery.Discover { @@ -23,7 +21,7 @@ namespace PoweredSoft.CQRS.DynamicQuery.Discover if (OverridableName != null) return OverridableName; - var pluralizer = new Pluralize.NET.Pluralizer(); + var pluralizer = new Pluralizer(); return pluralizer.Pluralize(DestinationType.Name); } } diff --git a/PoweredSoft.CQRS.DynamicQuery/DynamicQueryHandlerBase.cs b/PoweredSoft.CQRS.DynamicQuery/DynamicQueryHandlerBase.cs index df02463..7544861 100644 --- a/PoweredSoft.CQRS.DynamicQuery/DynamicQueryHandlerBase.cs +++ b/PoweredSoft.CQRS.DynamicQuery/DynamicQueryHandlerBase.cs @@ -83,8 +83,8 @@ namespace PoweredSoft.CQRS.DynamicQuery PageSize = query?.GetPageSize(), Filters = query?.GetFilters() ?? new List(), Sorts = query?.GetSorts() ?? new List(), - Groups = query.GetGroups() ?? new List(), - Aggregates = query.GetAggregates() ?? new List() + Groups = query?.GetGroups() ?? new List(), + Aggregates = query?.GetAggregates() ?? new List() }; return criteria; } diff --git a/PoweredSoft.CQRS.DynamicQuery/PoweredSoft.CQRS.DynamicQuery.csproj b/PoweredSoft.CQRS.DynamicQuery/PoweredSoft.CQRS.DynamicQuery.csproj index 7cbcd90..87a95fa 100644 --- a/PoweredSoft.CQRS.DynamicQuery/PoweredSoft.CQRS.DynamicQuery.csproj +++ b/PoweredSoft.CQRS.DynamicQuery/PoweredSoft.CQRS.DynamicQuery.csproj @@ -1,7 +1,6 @@  - - netstandard2.0 + netstandard2.1 Powered Softwares Inc. https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro PoweredSoft @@ -17,5 +16,4 @@ - diff --git a/PoweredSoft.CQRS.DynamicQuery/ServiceCollectionExtensions.cs b/PoweredSoft.CQRS.DynamicQuery/ServiceCollectionExtensions.cs index 773c4e6..12bdedb 100644 --- a/PoweredSoft.CQRS.DynamicQuery/ServiceCollectionExtensions.cs +++ b/PoweredSoft.CQRS.DynamicQuery/ServiceCollectionExtensions.cs @@ -5,9 +5,6 @@ using PoweredSoft.CQRS.Abstractions.Discovery; using PoweredSoft.CQRS.DynamicQuery.Abstractions; using PoweredSoft.CQRS.DynamicQuery.Discover; using PoweredSoft.DynamicQuery.Core; -using System; -using System.Collections.Generic; -using System.Text; namespace PoweredSoft.CQRS.DynamicQuery { @@ -22,7 +19,7 @@ namespace PoweredSoft.CQRS.DynamicQuery where TDestination : class { // add query handler. - services.AddTransient, IQueryExecutionResult>, DynamicQueryHandler>(); + services.AddTransient, IQueryExecutionResult>, DynamicQueryHandler>(); // add for discovery purposes. var queryType = typeof(IDynamicQuery); @@ -68,7 +65,7 @@ namespace PoweredSoft.CQRS.DynamicQuery where TParams : class { // add query handler. - services.AddTransient, IQueryExecutionResult>, DynamicQueryHandler>(); + services.AddTransient, IQueryExecutionResult>, DynamicQueryHandler>(); // add for discovery purposes. var queryType = typeof(IDynamicQuery); diff --git a/PoweredSoft.CQRS.FluentValidation/PoweredSoft.CQRS.FluentValidation.csproj b/PoweredSoft.CQRS.FluentValidation/PoweredSoft.CQRS.FluentValidation.csproj index ff8211a..ead9b61 100644 --- a/PoweredSoft.CQRS.FluentValidation/PoweredSoft.CQRS.FluentValidation.csproj +++ b/PoweredSoft.CQRS.FluentValidation/PoweredSoft.CQRS.FluentValidation.csproj @@ -1,7 +1,6 @@ - - netstandard2.0 + netstandard2.1 Powered Softwares Inc. https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro PoweredSoft @@ -9,11 +8,10 @@ - + - diff --git a/PoweredSoft.CQRS.FluentValidation/ServiceCollectionExtensions.cs b/PoweredSoft.CQRS.FluentValidation/ServiceCollectionExtensions.cs index e0a5da6..85172eb 100644 --- a/PoweredSoft.CQRS.FluentValidation/ServiceCollectionExtensions.cs +++ b/PoweredSoft.CQRS.FluentValidation/ServiceCollectionExtensions.cs @@ -1,12 +1,6 @@ using FluentValidation; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using PoweredSoft.CQRS.Abstractions; -using PoweredSoft.CQRS.Abstractions.Discovery; -using PoweredSoft.CQRS.Discovery; -using System; -using System.Collections.Generic; -using System.Text; namespace PoweredSoft.CQRS.FluentValidation { @@ -19,7 +13,7 @@ namespace PoweredSoft.CQRS.FluentValidation return services; } - public static IServiceCollection AddCommandWithValidator(this IServiceCollection services) + public static IServiceCollection AddCommand(this IServiceCollection services) where TCommand : class where TCommandHandler : class, ICommandHandler where TValidator : class, IValidator @@ -28,7 +22,7 @@ namespace PoweredSoft.CQRS.FluentValidation .AddFluentValidator(); } - public static IServiceCollection AddCommandWithValidator(this IServiceCollection services) + public static IServiceCollection AddCommand(this IServiceCollection services) where TCommand : class where TCommandHandler : class, ICommandHandler where TValidator : class, IValidator @@ -37,7 +31,7 @@ namespace PoweredSoft.CQRS.FluentValidation .AddFluentValidator(); } - public static IServiceCollection AddQueryWithValidator(this IServiceCollection services) + public static IServiceCollection AddQuery(this IServiceCollection services) where TQuery : class where TQueryHandler : class, IQueryHandler where TValidator : class, IValidator diff --git a/PoweredSoft.CQRS.GraphQL.Abstractions/IGraphQLFieldError.cs b/PoweredSoft.CQRS.GraphQL.Abstractions/IGraphQLFieldError.cs deleted file mode 100644 index f4fb65a..0000000 --- a/PoweredSoft.CQRS.GraphQL.Abstractions/IGraphQLFieldError.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace PoweredSoft.CQRS.GraphQL.Abstractions -{ - public interface IGraphQLFieldError - { - string Field { get; set; } - List Errors { get; set; } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.Abstractions/IGraphQLValidationResult.cs b/PoweredSoft.CQRS.GraphQL.Abstractions/IGraphQLValidationResult.cs deleted file mode 100644 index 1cc3d1d..0000000 --- a/PoweredSoft.CQRS.GraphQL.Abstractions/IGraphQLValidationResult.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; - -namespace PoweredSoft.CQRS.GraphQL.Abstractions -{ - public interface IGraphQLValidationResult - { - bool IsValid { get; } - - List Errors { get; } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.Abstractions/IGraphQLValidationService.cs b/PoweredSoft.CQRS.GraphQL.Abstractions/IGraphQLValidationService.cs deleted file mode 100644 index 1c5dd22..0000000 --- a/PoweredSoft.CQRS.GraphQL.Abstractions/IGraphQLValidationService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace PoweredSoft.CQRS.GraphQL.Abstractions -{ - - public interface IGraphQLValidationService - { - Task ValidateObjectAsync(object subject, CancellationToken cancellationToken = default); - Task ValidateAsync(T subject, CancellationToken cancellationToken = default); - } -} diff --git a/PoweredSoft.CQRS.GraphQL.Abstractions/PoweredSoft.CQRS.GraphQL.Abstractions.csproj b/PoweredSoft.CQRS.GraphQL.Abstractions/PoweredSoft.CQRS.GraphQL.Abstractions.csproj deleted file mode 100644 index 892921b..0000000 --- a/PoweredSoft.CQRS.GraphQL.Abstractions/PoweredSoft.CQRS.GraphQL.Abstractions.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - netstandard2.0 - Powered Softwares Inc. - https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro - PoweredSoft - PoweredSoft Team - - - diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAdvanceQueryAggregate.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAdvanceQueryAggregate.cs deleted file mode 100644 index a3d353c..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAdvanceQueryAggregate.cs +++ /dev/null @@ -1,21 +0,0 @@ -using PoweredSoft.DynamicQuery; -using PoweredSoft.DynamicQuery.Core; -using System; - -namespace PoweredSoft.CQRS.GraphQL -{ - public class GraphQLAdvanceQueryAggregate - { - public string Path { get; set; } - public AggregateType Type { get; set; } - - internal IAggregate ToAggregate() - { - return new Aggregate - { - Path = Path, - Type = Type - }; - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAdvanceQueryFilter.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAdvanceQueryFilter.cs deleted file mode 100644 index 9106aeb..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAdvanceQueryFilter.cs +++ /dev/null @@ -1,51 +0,0 @@ -using PoweredSoft.DynamicQuery; -using PoweredSoft.DynamicQuery.Core; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace PoweredSoft.CQRS.GraphQL.DynamicQuery -{ - public class GraphQLAdvanceQueryFilter - { - public bool? And { get; set; } - public FilterType Type { get; set; } - public bool? CaseInsensitive { get; set; } - public string Path { get; set; } - public GraphQLVariantInput Value { get; set; } - public bool? Not { get; set; } - - public List Filters { get; set; } - - internal IFilter ToFilter() - { - if (Type == FilterType.Composite) - { - var ret = new CompositeFilter - { - And = And, - Type = FilterType.Composite - }; - - if (Filters == null) - ret.Filters = new List(); - else - ret.Filters = Filters.Select(t => t.ToFilter()).ToList(); - - return ret; - } - else - { - return new SimpleFilter - { - And = And, - CaseInsensitive = CaseInsensitive, - Type = Type, - Not = Not, - Path = Path, - Value = Value.GetRawObjectValue() - }; - } - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAdvanceQueryGroup.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAdvanceQueryGroup.cs deleted file mode 100644 index b0b70cd..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAdvanceQueryGroup.cs +++ /dev/null @@ -1,21 +0,0 @@ -using PoweredSoft.DynamicQuery; -using PoweredSoft.DynamicQuery.Core; -using System; - -namespace PoweredSoft.CQRS.GraphQL -{ - public class GraphQLAdvanceQueryGroup - { - public string Path { get; set; } - public bool? Ascending { get; set; } - - internal IGroup ToGroup() - { - return new Group - { - Path = Path, - Ascending = Ascending - }; - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAggregateResult.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAggregateResult.cs deleted file mode 100644 index 7348070..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLAggregateResult.cs +++ /dev/null @@ -1,11 +0,0 @@ -using PoweredSoft.DynamicQuery.Core; - -namespace PoweredSoft.CQRS.GraphQL.DynamicQuery -{ - public class GraphQLAggregateResult - { - public string Path { get; set; } - public AggregateType Type { get; set; } - public GraphQLVariantResult Value { get; set; } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQuery.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQuery.cs deleted file mode 100644 index f3cf550..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQuery.cs +++ /dev/null @@ -1,73 +0,0 @@ -using PoweredSoft.CQRS.DynamicQuery.Abstractions; -using PoweredSoft.CQRS.GraphQL.DynamicQuery; -using PoweredSoft.DynamicQuery.Core; -using System.Collections.Generic; -using System.Linq; - -namespace PoweredSoft.CQRS.GraphQL.DynamicQuery -{ - public class GraphQLDynamicQuery : GraphQLDynamicQuery, IDynamicQuery - where TSource : class - where TDestination : class - { - - } - - public class GraphQLDynamicQuery : GraphQLDynamicQuery, - IDynamicQuery - where TSource : class - where TDestination : class - where TParams : class - { - public TParams Params { get; set; } - - public TParams GetParams() => Params; - } - - public class GraphQLDynamicQuery : IDynamicQuery - { - public int? Page { get; set; } - public int? PageSize { get; set; } - - public List Sorts { get; set; } - public List Filters { get; set; } - public List Groups { get; set; } - public List Aggregates { get; set; } - - public List GetAggregates() - { - if (Aggregates == null) - return new List(); - - return Aggregates.Select(a => a.ToAggregate()).ToList(); - } - - public List GetFilters() - { - if (Filters == null) - return new List(); - - return Filters.Select(t => t.ToFilter()).ToList(); - } - - public List GetGroups() - { - if (Groups == null) - return new List(); - - return Groups.Select(t => t.ToGroup()).ToList(); - } - - public int? GetPage() => Page; - - public int? GetPageSize() => PageSize; - - public List GetSorts() - { - if (Sorts == null) - return new List(); - - return Sorts.Select(t => t.ToSort()).ToList(); - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQueryExecutionResult.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQueryExecutionResult.cs deleted file mode 100644 index 4ce2aae..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQueryExecutionResult.cs +++ /dev/null @@ -1,59 +0,0 @@ -using PoweredSoft.DynamicQuery.Core; -using System.Collections.Generic; -using System.Linq; - -namespace PoweredSoft.CQRS.GraphQL.DynamicQuery -{ - public class GraphQLDynamicQueryExecutionResult : GraphQLDynamicQueryResult - { - public List> Groups { get; set; } - public long TotalRecords { get; set; } - public long? NumberOfPages { get; set; } - - public void FromResult(IQueryExecutionResult queryResult) - { - TotalRecords = queryResult.TotalRecords; - NumberOfPages = queryResult.NumberOfPages; - - - if (queryResult.Aggregates != null) - Aggregates = queryResult.Aggregates.Select(ConvertAggregateResult).ToList(); - - if (queryResult.Data != null) - Data = queryResult.Data; - - if (queryResult is IQueryExecutionGroupResult groupedResult) - Groups = groupedResult.Groups.Select(ConvertGroupResult).ToList(); - } - - protected virtual GraphQLDynamicQueryGroupResult ConvertGroupResult(IGroupQueryResult arg) - { - var group = new GraphQLDynamicQueryGroupResult(); - - group.GroupPath = arg.GroupPath; - group.GroupValue = new GraphQLVariantResult(arg.GroupValue); - - if (arg.Data != null) - group.Data = arg.Data; - - if (arg.Aggregates != null) - group.Aggregates = arg.Aggregates.Select(ConvertAggregateResult).ToList(); - - if (arg.HasSubGroups) - group.SubGroups = arg.SubGroups.Select(ConvertGroupResult).ToList(); - - return group; - } - - protected virtual GraphQLAggregateResult ConvertAggregateResult(IAggregateResult arg) - { - return new GraphQLAggregateResult - { - Path = arg.Path, - Type = arg.Type, - Value = new GraphQLVariantResult(arg.Value) - }; - } - - } -} diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQueryGroupResult.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQueryGroupResult.cs deleted file mode 100644 index 4e3b703..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQueryGroupResult.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace PoweredSoft.CQRS.GraphQL.DynamicQuery -{ - public class GraphQLDynamicQueryGroupResult : GraphQLDynamicQueryResult - { - public string GroupPath { get; set; } - public GraphQLVariantResult GroupValue { get; set; } - public bool HasSubGroups => SubGroups?.Any() == true; - public List> SubGroups { get; set; } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQueryResult.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQueryResult.cs deleted file mode 100644 index fe4973b..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLDynamicQueryResult.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace PoweredSoft.CQRS.GraphQL.DynamicQuery -{ - public class GraphQLDynamicQueryResult - { - public List Data { get; set; } - public List Aggregates { get; set; } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLSort.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLSort.cs deleted file mode 100644 index 0e0b6c5..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLSort.cs +++ /dev/null @@ -1,17 +0,0 @@ -using PoweredSoft.DynamicQuery; -using PoweredSoft.DynamicQuery.Core; -using System; - -namespace PoweredSoft.CQRS.GraphQL.DynamicQuery -{ - public class GraphQLSort - { - public string Path { get; set; } - public bool? Ascending { get; set; } - - internal ISort ToSort() - { - return new Sort(Path, Ascending); - } - } -} \ No newline at end of file diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLVariant.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLVariant.cs deleted file mode 100644 index 4a6401a..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLVariant.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; - -namespace PoweredSoft.CQRS.GraphQL.DynamicQuery -{ - public abstract class GraphQLVariant - { - - protected virtual string ResolveTypeName(object value) - { - if (value != null) - { - if (value is int) - return "int"; - if (value is long) - return "long"; - if (value is string) - return "string"; - if (value is bool) - return "boolean"; - if (value is decimal) - return "decimal"; - if (value is DateTime) - return "datetime"; - } - - return null; - } - - public string GetTypeName() - { - var value = GetRawObjectValue(); - return ResolveTypeName(value); - } - - public virtual void SetVariant(object raw) - { - ClearVariant(); - if (raw != null) - { - if (raw is int rawInt) - IntValue = rawInt; - if (raw is long rawLong) - LongValue = rawLong; - if (raw is string rawStr) - StringValue = rawStr; - if (raw is bool rawBool) - BooleanValue = rawBool; - if (raw is decimal rawDec) - DecimalValue = rawDec; - if (raw is DateTime rawDt) - DateTimeValue = rawDt; - } - } - - public virtual object GetRawObjectValue() - { - if (IntValue != null && IntValue is int) - return IntValue; - if (LongValue != null && LongValue is long) - return LongValue; - if (StringValue != null && StringValue is string) - return StringValue; - if (BooleanValue != null && BooleanValue is bool) - return BooleanValue; - if (DecimalValue != null && DecimalValue is decimal) - return DecimalValue; - if (DateTimeValue != null && DateTimeValue is DateTime) - return DateTimeValue; - - return null; - } - - public int? IntValue { get; set; } - public long? LongValue { get; set; } - public string StringValue { get; set; } - public decimal? DecimalValue { get; set; } - public DateTime? DateTimeValue { get; set; } - public bool? BooleanValue { get; set; } - - public virtual void ClearVariant() - { - this.IntValue = null; - this.LongValue = null; - this.StringValue = null; - this.DecimalValue = null; - this.DateTimeValue = null; - this.BooleanValue = null; - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLVariantInput.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLVariantInput.cs deleted file mode 100644 index ded90f3..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLVariantInput.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace PoweredSoft.CQRS.GraphQL.DynamicQuery -{ - public class GraphQLVariantInput : GraphQLVariant - { - } -} diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLVariantResult.cs b/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLVariantResult.cs deleted file mode 100644 index 5ce0475..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/GraphQLVariantResult.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Newtonsoft.Json; - -namespace PoweredSoft.CQRS.GraphQL.DynamicQuery -{ - public class GraphQLVariantResult : GraphQLVariant - { - public GraphQLVariantResult() - { - - } - - public GraphQLVariantResult(object raw) - { - SetVariant(raw); - } - - protected override string ResolveTypeName(object value) - { - var valueType = base.ResolveTypeName(value); - if (value != null && valueType == null) - return "json"; - - return valueType; - } - - public override object GetRawObjectValue() - { - if (jsonValue != null) - return jsonValue; - - return base.GetRawObjectValue(); - } - - private object jsonValue = null; - - public string Json - { - get - { - if (jsonValue != null) - return JsonConvert.SerializeObject(jsonValue, new JsonSerializerSettings - { - ReferenceLoopHandling = ReferenceLoopHandling.Ignore - }); - - return null; - } - set - { - jsonValue = JsonConvert.DeserializeObject(value); - } - } - - public override void ClearVariant() - { - base.ClearVariant(); - this.jsonValue = null; - } - } -} \ No newline at end of file diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/PoweredSoft.CQRS.GraphQL.DynamicQuery.csproj b/PoweredSoft.CQRS.GraphQL.DynamicQuery/PoweredSoft.CQRS.GraphQL.DynamicQuery.csproj deleted file mode 100644 index e6aa815..0000000 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/PoweredSoft.CQRS.GraphQL.DynamicQuery.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - netstandard2.0 - Powered Softwares Inc. - https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro - PoweredSoft - PoweredSoft Team - - - - - - - - - - - - - diff --git a/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLFieldError.cs b/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLFieldError.cs deleted file mode 100644 index 3125d25..0000000 --- a/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLFieldError.cs +++ /dev/null @@ -1,11 +0,0 @@ -using PoweredSoft.CQRS.GraphQL.Abstractions; -using System.Collections.Generic; - -namespace PoweredSoft.CQRS.GraphQL.FluentValidation -{ - public class GraphQLFieldError : IGraphQLFieldError - { - public string Field { get; set; } - public List Errors { get; set; } = new List(); - } -} diff --git a/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLFluentValidationResult.cs b/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLFluentValidationResult.cs deleted file mode 100644 index c5f1ddb..0000000 --- a/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLFluentValidationResult.cs +++ /dev/null @@ -1,28 +0,0 @@ -using FluentValidation.Results; -using PoweredSoft.CQRS.GraphQL.Abstractions; -using System.Collections.Generic; - -namespace PoweredSoft.CQRS.GraphQL.FluentValidation -{ - public class GraphQLFluentValidationResult : IGraphQLValidationResult - { - public bool IsValid => Errors.Count == 0; - public List Errors { get; } = new List(); - - public static GraphQLFluentValidationResult From(ValidationResult result) - { - var model = new GraphQLFluentValidationResult(); - foreach (var error in result.Errors) - { - var fieldError = new GraphQLFieldError - { - Field = error.PropertyName - }; - fieldError.Errors.Add(error.ErrorMessage); - model.Errors.Add(fieldError); - } - - return model; - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLFluentValidationService.cs b/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLFluentValidationService.cs deleted file mode 100644 index 516b912..0000000 --- a/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLFluentValidationService.cs +++ /dev/null @@ -1,47 +0,0 @@ -using FluentValidation; -using PoweredSoft.CQRS.GraphQL.Abstractions; -using System; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace PoweredSoft.CQRS.GraphQL.FluentValidation -{ - public class GraphQLFluentValidationService : IGraphQLValidationService - { - private readonly IServiceProvider serviceProvider; - - public GraphQLFluentValidationService(IServiceProvider serviceProvider) - { - this.serviceProvider = serviceProvider; - } - - public async Task ValidateAsync(T subject, CancellationToken cancellationToken = default) - { - var validationService = serviceProvider.GetService(typeof(IValidator)) as IValidator; - if (validationService == null) - return new GraphQLValidResult(); - - var result = await validationService.ValidateAsync(subject, cancellationToken); - if (!result.IsValid) - return GraphQLFluentValidationResult.From(result); - - return new GraphQLValidResult(); - } - - public async Task ValidateObjectAsync(object subject, CancellationToken cancellationToken = default) - { - var validatorType = typeof(IValidator<>).MakeGenericType(subject.GetType()); - var validationService = serviceProvider.GetService(validatorType) as IValidator; - if (validationService == null) - return new GraphQLValidResult(); - - var result = await validationService.ValidateAsync(new ValidationContext(subject), cancellationToken); - if (!result.IsValid) - return GraphQLFluentValidationResult.From(result); - - return new GraphQLValidResult(); - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLValidResult.cs b/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLValidResult.cs deleted file mode 100644 index 5f49a4e..0000000 --- a/PoweredSoft.CQRS.GraphQL.FluentValidation/GraphQLValidResult.cs +++ /dev/null @@ -1,11 +0,0 @@ -using PoweredSoft.CQRS.GraphQL.Abstractions; -using System.Collections.Generic; - -namespace PoweredSoft.CQRS.GraphQL.FluentValidation -{ - public class GraphQLValidResult : IGraphQLValidationResult - { - public bool IsValid => true; - public List Errors { get; } = new List(); - } -} diff --git a/PoweredSoft.CQRS.GraphQL.FluentValidation/PoweredSoft.CQRS.GraphQL.FluentValidation.csproj b/PoweredSoft.CQRS.GraphQL.FluentValidation/PoweredSoft.CQRS.GraphQL.FluentValidation.csproj deleted file mode 100644 index c440e6b..0000000 --- a/PoweredSoft.CQRS.GraphQL.FluentValidation/PoweredSoft.CQRS.GraphQL.FluentValidation.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - netstandard2.0 - Powered Softwares Inc. - https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro - PoweredSoft - PoweredSoft Team - - - - - - - - - - - - diff --git a/PoweredSoft.CQRS.GraphQL.FluentValidation/ServiceCollectionExtensions.cs b/PoweredSoft.CQRS.GraphQL.FluentValidation/ServiceCollectionExtensions.cs deleted file mode 100644 index a0dcb57..0000000 --- a/PoweredSoft.CQRS.GraphQL.FluentValidation/ServiceCollectionExtensions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using PoweredSoft.CQRS.GraphQL.Abstractions; - -namespace PoweredSoft.CQRS.GraphQL.FluentValidation -{ - public static class ServiceCollectionExtensions - { - public static IServiceCollection AddPoweredSoftGraphQLFluentValidation(this IServiceCollection services) - { - services.AddTransient(); - return services; - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/DynamicQueryObjectType.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/DynamicQueryObjectType.cs deleted file mode 100644 index 192bca0..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/DynamicQueryObjectType.cs +++ /dev/null @@ -1,90 +0,0 @@ -using HotChocolate.Types; -using PoweredSoft.CQRS.Abstractions; -using PoweredSoft.CQRS.Abstractions.Discovery; -using PoweredSoft.CQRS.DynamicQuery.Discover; -using System; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery -{ - - internal class DynamicQueryObjectType : ObjectTypeExtension - { - private readonly IQueryDiscovery queryDiscovery; - - public DynamicQueryObjectType(IQueryDiscovery queryDiscovery) : base() - { - this.queryDiscovery = queryDiscovery; - } - - protected override void Configure(IObjectTypeDescriptor descriptor) - { - base.Configure(descriptor); - descriptor.Name("Query"); - - foreach(var q in queryDiscovery.GetQueries()) - { - if (q.Category == "DynamicQuery" && q is DynamicQueryMeta dq) - { - var f = descriptor.Field(q.LowerCamelCaseName); - - // service to execute with. - var queryHandlerServiceType = typeof(IQueryHandler<,>).MakeGenericType(dq.QueryType, dq.QueryResultType); - - // destermine argument type. - Type argumentType; - Type runnerType; - if (dq.ParamsType != null) - { - argumentType = typeof(GraphQL.DynamicQuery.GraphQLDynamicQuery<,,>).MakeGenericType( - dq.SourceType, dq.DestinationType, dq.ParamsType); - - runnerType = typeof(DynamicQueryRunnerWithParams<,,>) - .MakeGenericType(dq.SourceType, dq.DestinationType, dq.ParamsType); - } - else - { - argumentType = typeof(GraphQL.DynamicQuery.GraphQLDynamicQuery<,>).MakeGenericType( - dq.SourceType, dq.DestinationType); - - runnerType = typeof(DynamicQueryRunner<,>) - .MakeGenericType(dq.SourceType, dq.DestinationType); - } - - f.Argument("params", a => a - .Type(argumentType) - .DefaultValue(Activator.CreateInstance(argumentType)) - ); - - // make generic type of outgoing type. - var resultType = typeof(GraphQL.DynamicQuery.GraphQLDynamicQueryExecutionResult<>) - .MakeGenericType(dq.DestinationType); - - f.Type(resultType); - - // security middleware - f.Use((sp, d) => new QueryAuthorizationMiddleware(q.QueryType, d)); - - // middleware to validate. - f.Use(); - - // resolver - f.Resolve(async r => - { - dynamic argument = r.ArgumentValue("params"); - - // handler service. - var service = r.Service(queryHandlerServiceType); - - // runner. - dynamic runner = Activator.CreateInstance(runnerType, new object[] { service }); - - // get outcome. - object outcome = await runner.RunAsync(argument, r.RequestAborted); - - return outcome; - }); - } - } - } - } -} \ No newline at end of file diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/DynamicQueryRunner.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/DynamicQueryRunner.cs deleted file mode 100644 index 320012f..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/DynamicQueryRunner.cs +++ /dev/null @@ -1,28 +0,0 @@ -using PoweredSoft.CQRS.DynamicQuery; -using PoweredSoft.CQRS.DynamicQuery.Abstractions; -using PoweredSoft.CQRS.GraphQL.DynamicQuery; -using System.Threading; -using System.Threading.Tasks; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery -{ - public class DynamicQueryRunner - where TSource : class - where TDestination : class - { - private readonly DynamicQueryHandler handler; - - public DynamicQueryRunner(DynamicQueryHandler handler) - { - this.handler = handler; - } - - public async Task> RunAsync(IDynamicQuery query, CancellationToken cancellationToken = default) - { - var result = await handler.HandleAsync(query); - var outcome = new GraphQLDynamicQueryExecutionResult(); - outcome.FromResult(result); - return outcome; - } - } -} \ No newline at end of file diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/DynamicQueryRunnerWithParams.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/DynamicQueryRunnerWithParams.cs deleted file mode 100644 index f40702c..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/DynamicQueryRunnerWithParams.cs +++ /dev/null @@ -1,29 +0,0 @@ -using PoweredSoft.CQRS.DynamicQuery; -using PoweredSoft.CQRS.DynamicQuery.Abstractions; -using PoweredSoft.CQRS.GraphQL.DynamicQuery; -using System.Threading; -using System.Threading.Tasks; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery -{ - public class DynamicQueryRunnerWithParams - where TSource : class - where TDestination : class - where TParams : class - { - private readonly DynamicQueryHandler handler; - - public DynamicQueryRunnerWithParams(DynamicQueryHandler handler) - { - this.handler = handler; - } - - public async Task> RunAsync(IDynamicQuery query, CancellationToken cancellationToken = default) - { - var result = await handler.HandleAsync(query); - var outcome = new GraphQLDynamicQueryExecutionResult(); - outcome.FromResult(result); - return outcome; - } - } -} \ No newline at end of file diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery.csproj b/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery.csproj deleted file mode 100644 index 364ff45..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - netcoreapp3.1;net5.0 - Powered Softwares Inc. - https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro - PoweredSoft - PoweredSoft Team - - - - - - - - - - - - - diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/RequestExecutorBuilderExtensions.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/RequestExecutorBuilderExtensions.cs deleted file mode 100644 index 6258e0b..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/RequestExecutorBuilderExtensions.cs +++ /dev/null @@ -1,15 +0,0 @@ -using HotChocolate.Execution.Configuration; -using Microsoft.Extensions.DependencyInjection; -using System; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery -{ - public static class RequestExecutorBuilderExtensions - { - public static IRequestExecutorBuilder AddPoweredSoftDynamicQueries(this IRequestExecutorBuilder builder) - { - builder.AddTypeExtension(); - return builder; - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationAuthorizationMiddleware.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationAuthorizationMiddleware.cs deleted file mode 100644 index afc2cfa..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationAuthorizationMiddleware.cs +++ /dev/null @@ -1,46 +0,0 @@ -using HotChocolate; -using HotChocolate.Resolvers; -using System; -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using PoweredSoft.CQRS.Abstractions.Security; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate -{ - internal class MutationAuthorizationMiddleware - { - private readonly Type mutationType; - private readonly FieldDelegate _next; - - public MutationAuthorizationMiddleware(Type mutationType,FieldDelegate next) - { - this.mutationType = mutationType; - _next = next; - } - - public async Task InvokeAsync(IMiddlewareContext context) - { - var mutationAuthorizationService = context.Service().GetService(); - if (mutationAuthorizationService != null) - { - var authorizationResult = await mutationAuthorizationService.IsAllowedAsync(mutationType); - if (authorizationResult != AuthorizationResult.Allowed) - { - var eb = ErrorBuilder.New() - .SetMessage(authorizationResult == AuthorizationResult.Unauthorized ? "Unauthorized" : "Forbidden") - .SetCode("AuthorizationResult") - .SetExtension("StatusCode", authorizationResult == AuthorizationResult.Unauthorized ? "401" : "403") - .SetPath(context.Path) - .AddLocation(context.Selection.SyntaxNode); - - context.Result = eb.Build(); - - return; - } - } - - - await _next.Invoke(context); - } - } -} \ No newline at end of file diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationObjectType.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationObjectType.cs deleted file mode 100644 index 2cc00d8..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationObjectType.cs +++ /dev/null @@ -1,79 +0,0 @@ -using HotChocolate.Resolvers; -using HotChocolate.Types; -using PoweredSoft.CQRS.Abstractions; -using PoweredSoft.CQRS.Abstractions.Discovery; -using System; -using System.Collections.Generic; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate -{ - public class MutationObjectType : ObjectTypeExtension - { - private readonly ICommandDiscovery commandDiscovery; - - public MutationObjectType(ICommandDiscovery commandDiscovery) : base() - { - this.commandDiscovery = commandDiscovery; - } - - protected override void Configure(IObjectTypeDescriptor desc) - { - desc.Name("Mutation"); - foreach (var m in commandDiscovery.GetCommands()) - { - var mutationField = desc.Field(m.LowerCamelCaseName); - - Type typeToGet; - if (m.CommandResultType == null) - typeToGet = typeof(ICommandHandler<>).MakeGenericType(m.CommandType); - else - typeToGet = typeof(ICommandHandler<,>).MakeGenericType(m.CommandType, m.CommandResultType); - - if (m.CommandResultType == null) - mutationField.Type(typeof(int?)); - else - mutationField.Type(m.CommandResultType); - - //queryField.Use((sp, d) => new MutationAuthorizationMiddleware(m.CommandType, d)); - - if (m.CommandType.GetProperties().Length == 0) - { - mutationField.Resolve(async ctx => - { - var queryArgument = Activator.CreateInstance(m.CommandType); - return await HandleMutation(m.CommandResultType != null, ctx, typeToGet, queryArgument); - }); - - continue; - } - - mutationField.Argument("params", t => t.Type(m.CommandType)); - - mutationField.Resolve(async ctx => - { - var queryArgument = ctx.ArgumentValue("params"); - return await HandleMutation(m.CommandResultType != null, ctx, typeToGet, queryArgument); - }); - - mutationField.Use(); - mutationField.Use(); - } - } - - private async System.Threading.Tasks.Task HandleMutation(bool hasResult, IResolverContext ctx, Type typeToGet, object queryArgument) - { - dynamic service = ctx.Service(typeToGet); - - if (hasResult) - { - var result = await service.HandleAsync((dynamic)queryArgument); - return result; - } - else - { - await service.HandleAsync((dynamic)queryArgument); - return null; - } - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationParamRequiredMiddleware.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationParamRequiredMiddleware.cs deleted file mode 100644 index ba5a697..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationParamRequiredMiddleware.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HotChocolate; -using HotChocolate.Resolvers; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate -{ - public class MutationParamRequiredMiddleware - { - private readonly FieldDelegate _next; - - public MutationParamRequiredMiddleware(FieldDelegate next) - { - _next = next; - } - - public async Task InvokeAsync(IMiddlewareContext context) - { - var queryArgument = context.ArgumentValue("params"); - if (queryArgument == null) - { - context.Result = ErrorBuilder.New() - .SetMessage("mutation argument is required") - .SetCode("400") - .SetPath(context.Path) - .AddLocation(context.Selection.SyntaxNode) - .Build(); - - return; - } - - await _next.Invoke(context); - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationValidationMiddleware.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationValidationMiddleware.cs deleted file mode 100644 index 1c30efb..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate/MutationValidationMiddleware.cs +++ /dev/null @@ -1,47 +0,0 @@ -using HotChocolate; -using HotChocolate.Resolvers; -using PoweredSoft.CQRS.GraphQL.Abstractions; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate -{ - public class MutationValidationMiddleware - { - private readonly FieldDelegate _next; - - public MutationValidationMiddleware(FieldDelegate next) - { - _next = next; - } - - public async Task InvokeAsync(IMiddlewareContext context) - { - var queryArgument = context.ArgumentValue("params"); - if (queryArgument != null) - { - var service = context.Service(); - var result = await service.ValidateObjectAsync(queryArgument, context.RequestAborted); - if (!result.IsValid) - { - var eb = ErrorBuilder.New() - .SetMessage("There are some validations errors") - .SetCode("ValidationError") - .SetPath(context.Path) - .AddLocation(context.Selection.SyntaxNode); - - foreach (var error in result.Errors) - eb.SetExtension(error.Field, error.Errors); - - context.Result = eb.Build(); - - return; - } - } - - await _next.Invoke(context); - } - } -} diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate/PoweredSoft.CQRS.GraphQL.HotChocolate.csproj b/PoweredSoft.CQRS.GraphQL.HotChocolate/PoweredSoft.CQRS.GraphQL.HotChocolate.csproj deleted file mode 100644 index 0a7655f..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate/PoweredSoft.CQRS.GraphQL.HotChocolate.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - netcoreapp3.1;net5.0 - Powered Softwares Inc. - https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro - PoweredSoft - PoweredSoft Team - - - - - - - - - - - - - diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate/QueryAuthorizationMiddleware.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate/QueryAuthorizationMiddleware.cs deleted file mode 100644 index f1cf2e3..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate/QueryAuthorizationMiddleware.cs +++ /dev/null @@ -1,46 +0,0 @@ -using HotChocolate; -using HotChocolate.Resolvers; -using Microsoft.Extensions.DependencyInjection; -using PoweredSoft.CQRS.Abstractions.Security; -using System; -using System.Threading.Tasks; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate -{ - public class QueryAuthorizationMiddleware - { - private readonly Type queryType; - private readonly FieldDelegate _next; - - public QueryAuthorizationMiddleware(Type queryType, FieldDelegate next) - { - this.queryType = queryType; - _next = next; - } - - public async Task InvokeAsync(IMiddlewareContext context) - { - var queryAuthorizationService = context.Service().GetService(); - if (queryAuthorizationService != null) - { - var authorizationResult = await queryAuthorizationService.IsAllowedAsync(queryType); - if (authorizationResult != AuthorizationResult.Allowed) - { - var eb = ErrorBuilder.New() - .SetMessage(authorizationResult == AuthorizationResult.Unauthorized ? "Unauthorized" : "Forbidden") - .SetCode("AuthorizationResult") - .SetExtension("StatusCode", authorizationResult == AuthorizationResult.Unauthorized ? "401" : "403") - .SetPath(context.Path) - .AddLocation(context.Selection.SyntaxNode); - - context.Result = eb.Build(); - - return; - } - } - - - await _next.Invoke(context); - } - } -} \ No newline at end of file diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate/QueryObjectType.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate/QueryObjectType.cs deleted file mode 100644 index a96673c..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate/QueryObjectType.cs +++ /dev/null @@ -1,89 +0,0 @@ -using HotChocolate.Language; -using HotChocolate.Resolvers; -using HotChocolate.Types; -using PoweredSoft.CQRS.Abstractions; -using PoweredSoft.CQRS.Abstractions.Discovery; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate -{ - public class QueryObjectType : ObjectTypeExtension - { - private readonly IQueryDiscovery queryDiscovery; - - public QueryObjectType(IQueryDiscovery queryDiscovery) : base() - { - this.queryDiscovery = queryDiscovery; - } - - protected override void Configure(IObjectTypeDescriptor desc) - { - desc.Name("Query"); - foreach (var q in queryDiscovery.GetQueries()) - { - if (q.Category != "BasicQuery") - continue; - - var queryField = desc.Field(q.LowerCamelCaseName); - var typeToGet = typeof(IQueryHandler<,>).MakeGenericType(q.QueryType, q.QueryResultType); - - queryField.Use((sp, d) => new QueryAuthorizationMiddleware(q.QueryType, d)); - - // if its a IQueryable. - if (q.QueryResultType.Namespace == "System.Linq" && q.QueryResultType.Name.Contains("IQueryable")) - { - //waiting on answer to be determined. - //this does not work - //var genericArgument = q.QueryResultType.GetGenericArguments().First(); - //var objectTypeOfAargument = typeof(ObjectType<>).MakeGenericType(genericArgument); - //var listType = typeof(ListType<>).MakeGenericType(objectTypeOfAargument); - //queryField.Type(objectTypeOfAargument); - //queryField.UseSingleOrDefault(); - //queryField.UseProjection(); - ////queryField.UsePaging(listType); - queryField.Type(q.QueryResultType); - } - else - { - queryField.Type(q.QueryResultType); - - } - - if (q.QueryType.GetProperties().Length == 0) - { - queryField.Resolve(async ctx => - { - var queryArgument = Activator.CreateInstance(q.QueryType); - return await HandleQuery(ctx, typeToGet, queryArgument); - }); - - continue; - } - - queryField.Argument("params", t => t.Type(q.QueryType)); - - queryField.Resolve(async ctx => - { - var queryArgument = ctx.ArgumentValue("params"); - return await HandleQuery(ctx, typeToGet, queryArgument); - }); - - /* - if (q.QueryObjectRequired) - queryField.Use();*/ - - queryField.Use(); - } - } - - private async System.Threading.Tasks.Task HandleQuery(IResolverContext resolverContext, Type typeToGet, object queryArgument) - { - dynamic service = resolverContext.Service(typeToGet); - var result = await service.HandleAsync((dynamic)queryArgument); - return result; - } - } -} \ No newline at end of file diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate/QueryValidationMiddleware.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate/QueryValidationMiddleware.cs deleted file mode 100644 index 3415e88..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate/QueryValidationMiddleware.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using HotChocolate; -using HotChocolate.Resolvers; -using Newtonsoft.Json; -using PoweredSoft.CQRS.GraphQL.Abstractions; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate -{ - public class QueryValidationMiddleware - { - private readonly FieldDelegate _next; - - public QueryValidationMiddleware(FieldDelegate next) - { - _next = next; - } - - public async Task InvokeAsync(IMiddlewareContext context) - { - var queryArgument = context.ArgumentValue("params"); - if (queryArgument != null) - { - var service = context.Service(); - var result = await service.ValidateObjectAsync(queryArgument, context.RequestAborted); - if (!result.IsValid) - { - var eb = ErrorBuilder.New() - .SetMessage("There are some validations errors") - .SetCode("ValidationError") - .SetPath(context.Path) - .AddLocation(context.Selection.SyntaxNode); - - foreach (var error in result.Errors) - eb.SetExtension(error.Field, error.Errors); - - context.Result = eb.Build(); - - return; - } - } - - await _next.Invoke(context); - } - } -} \ No newline at end of file diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate/RequestExecutorBuilderExtensions.cs b/PoweredSoft.CQRS.GraphQL.HotChocolate/RequestExecutorBuilderExtensions.cs deleted file mode 100644 index 05f7804..0000000 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate/RequestExecutorBuilderExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -using HotChocolate; -using HotChocolate.Execution.Configuration; -using Microsoft.Extensions.DependencyInjection; -using System; - -namespace PoweredSoft.CQRS.GraphQL.HotChocolate -{ - public static class RequestExecutorBuilderExtensions - { - public static IRequestExecutorBuilder AddPoweredSoftQueries(this IRequestExecutorBuilder builder) - { - builder.AddTypeExtension(); - return builder; - } - - public static IRequestExecutorBuilder AddPoweredSoftMutations(this IRequestExecutorBuilder builder) - { - builder.AddTypeExtension(); - return builder; - } - } -} diff --git a/PoweredSoft.CQRS.sln b/PoweredSoft.CQRS.sln index 88ddd77..4256da3 100644 --- a/PoweredSoft.CQRS.sln +++ b/PoweredSoft.CQRS.sln @@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.AspNetCore EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.AspNetCore.Abstractions", "PoweredSoft.CQRS.AspNetCore.Abstractions\PoweredSoft.CQRS.AspNetCore.Abstractions.csproj", "{4C466827-31D3-4081-A751-C2FC7C381D7E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "Demo\Demo.csproj", "{F15B1E11-8D4C-489E-AFF7-AA144105FE46}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{617BA357-1A1F-40C5-B19A-A65A960E6142}" ProjectSection(SolutionItems) = preProject LICENSE = LICENSE @@ -25,16 +23,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.DynamicQue EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.DynamicQuery.AspNetCore", "PoweredSoft.CQRS.DynamicQuery.AspNetCore\PoweredSoft.CQRS.DynamicQuery.AspNetCore.csproj", "{0829B99A-0A20-4CAC-A91E-FB67E18444DE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.GraphQL.HotChocolate", "PoweredSoft.CQRS.GraphQL.HotChocolate\PoweredSoft.CQRS.GraphQL.HotChocolate.csproj", "{BF8E3B0D-8651-4541-892F-F607C5E80F9B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.GraphQL.Abstractions", "PoweredSoft.CQRS.GraphQL.Abstractions\PoweredSoft.CQRS.GraphQL.Abstractions.csproj", "{C18DD3EB-56A8-4576-BB31-04AE724E6E25}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.GraphQL.FluentValidation", "PoweredSoft.CQRS.GraphQL.FluentValidation\PoweredSoft.CQRS.GraphQL.FluentValidation.csproj", "{BB134663-BAB0-45C4-A6E0-34F296FCA7AE}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery", "PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery\PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery.csproj", "{8921D74D-DA6E-4DAF-BE85-7BE5229FE95C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.GraphQL.DynamicQuery", "PoweredSoft.CQRS.GraphQL.DynamicQuery\PoweredSoft.CQRS.GraphQL.DynamicQuery.csproj", "{34B27880-A5D5-47EA-A5FA-86E04E0F7A21}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.FluentValidation", "PoweredSoft.CQRS.FluentValidation\PoweredSoft.CQRS.FluentValidation.csproj", "{70BD37C4-7497-474D-9A40-A701203971D8}" EndProject Global @@ -59,10 +47,6 @@ Global {4C466827-31D3-4081-A751-C2FC7C381D7E}.Debug|Any CPU.Build.0 = Debug|Any CPU {4C466827-31D3-4081-A751-C2FC7C381D7E}.Release|Any CPU.ActiveCfg = Release|Any CPU {4C466827-31D3-4081-A751-C2FC7C381D7E}.Release|Any CPU.Build.0 = Release|Any CPU - {F15B1E11-8D4C-489E-AFF7-AA144105FE46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F15B1E11-8D4C-489E-AFF7-AA144105FE46}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F15B1E11-8D4C-489E-AFF7-AA144105FE46}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F15B1E11-8D4C-489E-AFF7-AA144105FE46}.Release|Any CPU.Build.0 = Release|Any CPU {A38CE930-191F-417C-B5BE-8CC62DB47513}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A38CE930-191F-417C-B5BE-8CC62DB47513}.Debug|Any CPU.Build.0 = Debug|Any CPU {A38CE930-191F-417C-B5BE-8CC62DB47513}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -75,26 +59,6 @@ Global {0829B99A-0A20-4CAC-A91E-FB67E18444DE}.Debug|Any CPU.Build.0 = Debug|Any CPU {0829B99A-0A20-4CAC-A91E-FB67E18444DE}.Release|Any CPU.ActiveCfg = Release|Any CPU {0829B99A-0A20-4CAC-A91E-FB67E18444DE}.Release|Any CPU.Build.0 = Release|Any CPU - {BF8E3B0D-8651-4541-892F-F607C5E80F9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BF8E3B0D-8651-4541-892F-F607C5E80F9B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BF8E3B0D-8651-4541-892F-F607C5E80F9B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BF8E3B0D-8651-4541-892F-F607C5E80F9B}.Release|Any CPU.Build.0 = Release|Any CPU - {C18DD3EB-56A8-4576-BB31-04AE724E6E25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C18DD3EB-56A8-4576-BB31-04AE724E6E25}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C18DD3EB-56A8-4576-BB31-04AE724E6E25}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C18DD3EB-56A8-4576-BB31-04AE724E6E25}.Release|Any CPU.Build.0 = Release|Any CPU - {BB134663-BAB0-45C4-A6E0-34F296FCA7AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB134663-BAB0-45C4-A6E0-34F296FCA7AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB134663-BAB0-45C4-A6E0-34F296FCA7AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB134663-BAB0-45C4-A6E0-34F296FCA7AE}.Release|Any CPU.Build.0 = Release|Any CPU - {8921D74D-DA6E-4DAF-BE85-7BE5229FE95C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8921D74D-DA6E-4DAF-BE85-7BE5229FE95C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8921D74D-DA6E-4DAF-BE85-7BE5229FE95C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8921D74D-DA6E-4DAF-BE85-7BE5229FE95C}.Release|Any CPU.Build.0 = Release|Any CPU - {34B27880-A5D5-47EA-A5FA-86E04E0F7A21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {34B27880-A5D5-47EA-A5FA-86E04E0F7A21}.Debug|Any CPU.Build.0 = Debug|Any CPU - {34B27880-A5D5-47EA-A5FA-86E04E0F7A21}.Release|Any CPU.ActiveCfg = Release|Any CPU - {34B27880-A5D5-47EA-A5FA-86E04E0F7A21}.Release|Any CPU.Build.0 = Release|Any CPU {70BD37C4-7497-474D-9A40-A701203971D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {70BD37C4-7497-474D-9A40-A701203971D8}.Debug|Any CPU.Build.0 = Debug|Any CPU {70BD37C4-7497-474D-9A40-A701203971D8}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/PoweredSoft.CQRS/Discovery/CommandDiscovery.cs b/PoweredSoft.CQRS/Discovery/CommandDiscovery.cs index 53f6d33..ffc7d21 100644 --- a/PoweredSoft.CQRS/Discovery/CommandDiscovery.cs +++ b/PoweredSoft.CQRS/Discovery/CommandDiscovery.cs @@ -1,7 +1,7 @@ -using PoweredSoft.CQRS.Abstractions.Discovery; -using System; +using System; using System.Collections.Generic; using System.Linq; +using PoweredSoft.CQRS.Abstractions.Discovery; namespace PoweredSoft.CQRS.Discovery { diff --git a/PoweredSoft.CQRS/Discovery/QueryDiscovery.cs b/PoweredSoft.CQRS/Discovery/QueryDiscovery.cs index 4f4a1f8..e2240da 100644 --- a/PoweredSoft.CQRS/Discovery/QueryDiscovery.cs +++ b/PoweredSoft.CQRS/Discovery/QueryDiscovery.cs @@ -1,8 +1,7 @@ -using PoweredSoft.CQRS.Abstractions.Discovery; -using System; +using System; using System.Collections.Generic; using System.Linq; -using System.Text; +using PoweredSoft.CQRS.Abstractions.Discovery; namespace PoweredSoft.CQRS.Discovery { diff --git a/PoweredSoft.CQRS/PoweredSoft.CQRS.csproj b/PoweredSoft.CQRS/PoweredSoft.CQRS.csproj index d081319..e8d4611 100644 --- a/PoweredSoft.CQRS/PoweredSoft.CQRS.csproj +++ b/PoweredSoft.CQRS/PoweredSoft.CQRS.csproj @@ -1,19 +1,13 @@  - - netstandard2.0 + netstandard2.1 Powered Softwares Inc. https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro PoweredSoft PoweredSoft Team - - - - - diff --git a/PoweredSoft.CQRS/ServiceCollectionExtensions.cs b/PoweredSoft.CQRS/ServiceCollectionExtensions.cs index b1dbb0a..57b1356 100644 --- a/PoweredSoft.CQRS/ServiceCollectionExtensions.cs +++ b/PoweredSoft.CQRS/ServiceCollectionExtensions.cs @@ -1,18 +1,21 @@ -using Microsoft.Extensions.DependencyInjection; +using System; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using PoweredSoft.CQRS.Abstractions.Discovery; using PoweredSoft.CQRS.Discovery; -using System; -using System.Collections.Generic; -using System.Text; namespace PoweredSoft.CQRS { public static class ServiceCollectionExtensions { - public static IServiceCollection AddPoweredSoftCQRS(this IServiceCollection services) + public static IServiceCollection AddDefaultQueryDiscovery(this IServiceCollection services) { services.TryAddTransient(); + return services; + } + + public static IServiceCollection AddDefaultCommandDiscovery(this IServiceCollection services) + { services.TryAddTransient(); return services; }