Browse Source

Less hacks.

pull/349/head
Sebastian Stehle 7 years ago
parent
commit
50d919aec5
  1. 1
      extensions/Squidex.Extensions/Actions/Algolia/AlgoliaAction.cs
  2. 3
      extensions/Squidex.Extensions/Actions/Algolia/AlgoliaPlugin.cs
  3. 1
      extensions/Squidex.Extensions/Actions/AzureQueue/AzureQueueAction.cs
  4. 3
      extensions/Squidex.Extensions/Actions/AzureQueue/AzureQueuePlugin.cs
  5. 1
      extensions/Squidex.Extensions/Actions/Discourse/DiscourseAction.cs
  6. 3
      extensions/Squidex.Extensions/Actions/Discourse/DiscoursePlugin.cs
  7. 1
      extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchAction.cs
  8. 3
      extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchPlugin.cs
  9. 1
      extensions/Squidex.Extensions/Actions/Email/EmailAction.cs
  10. 3
      extensions/Squidex.Extensions/Actions/Email/EmailPlugin.cs
  11. 1
      extensions/Squidex.Extensions/Actions/Fastly/FastlyAction.cs
  12. 3
      extensions/Squidex.Extensions/Actions/Fastly/FastlyPlugin.cs
  13. 1
      extensions/Squidex.Extensions/Actions/Medium/MediumAction.cs
  14. 3
      extensions/Squidex.Extensions/Actions/Medium/MediumPlugin.cs
  15. 1
      extensions/Squidex.Extensions/Actions/Prerender/PrerenderAction.cs
  16. 3
      extensions/Squidex.Extensions/Actions/Prerender/PrerenderPlugin.cs
  17. 1
      extensions/Squidex.Extensions/Actions/Slack/SlackAction.cs
  18. 3
      extensions/Squidex.Extensions/Actions/Slack/SlackPlugin.cs
  19. 1
      extensions/Squidex.Extensions/Actions/Twitter/TweetAction.cs
  20. 3
      extensions/Squidex.Extensions/Actions/Twitter/TwitterPlugin.cs
  21. 1
      extensions/Squidex.Extensions/Actions/Webhook/WebhookAction.cs
  22. 3
      extensions/Squidex.Extensions/Actions/Webhook/WebhookPlugin.cs
  23. 6
      src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRegistry.cs
  24. 2
      src/Squidex.Domain.Apps.Core.Model/SquidexCoreModel.cs
  25. 25
      src/Squidex.Domain.Apps.Core.Operations/HandleRules/DependencyInjectionExtensions.cs
  26. 30
      src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionHandlerAttribute.cs
  27. 24
      src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionRegistration.cs
  28. 175
      src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionRegistry.cs
  29. 140
      src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleRegistry.cs
  30. 2
      src/Squidex.Domain.Apps.Events/SquidexEvents.cs
  31. 9
      src/Squidex.Infrastructure.MongoDb/States/MongoSnapshotStore.cs
  32. 17
      src/Squidex.Infrastructure/AutoAssembyTypeProvider.cs
  33. 4
      src/Squidex.Infrastructure/Configuration/ConfigurationExtensions.cs
  34. 2
      src/Squidex.Infrastructure/Configuration/Options.cs
  35. 4
      src/Squidex.Infrastructure/DependencyInjection/DependencyInjectionExtensions.cs
  36. 14
      src/Squidex.Infrastructure/ITypeProvider.cs
  37. 2
      src/Squidex.Infrastructure/Log/ApplicationInfoLogAppender.cs
  38. 2
      src/Squidex.Infrastructure/Reflection/ReflectionExtensions.cs
  39. 2
      src/Squidex.Infrastructure/SquidexInfrastructure.cs
  40. 22
      src/Squidex.Infrastructure/TypeNameRegistry.cs
  41. 1
      src/Squidex/Areas/Api/Config/Swagger/SwaggerServices.cs
  42. 2
      src/Squidex/Areas/Api/Config/Swagger/XmlTagProcessor.cs
  43. 4
      src/Squidex/Areas/Api/Controllers/Rules/Models/RuleActionConverter.cs
  44. 16
      src/Squidex/Areas/Api/Controllers/Rules/Models/RuleActionProcessor.cs
  45. 11
      src/Squidex/Areas/Api/Controllers/Rules/RulesController.cs
  46. 3
      src/Squidex/Areas/Api/Controllers/Users/UsersController.cs
  47. 3
      src/Squidex/Areas/IdentityServer/Config/IdentityServerServices.cs
  48. 2
      src/Squidex/Config/Domain/AssetServices.cs
  49. 2
      src/Squidex/Config/Domain/EntitiesServices.cs
  50. 1
      src/Squidex/Config/Domain/EventPublishersServices.cs
  51. 12
      src/Squidex/Config/Domain/EventStoreServices.cs
  52. 1
      src/Squidex/Config/Domain/InfrastructureServices.cs
  53. 1
      src/Squidex/Config/Domain/LoggingServices.cs
  54. 10
      src/Squidex/Config/Domain/RuleServices.cs
  55. 41
      src/Squidex/Config/Domain/SerializationInitializer.cs
  56. 68
      src/Squidex/Config/Domain/SerializationServices.cs
  57. 27
      src/Squidex/Config/Domain/StoreServices.cs
  58. 1
      src/Squidex/Config/Domain/SubscriptionServices.cs
  59. 1
      src/Squidex/Config/Orleans/OrleansServices.cs
  60. 1
      src/Squidex/Config/Web/WebServices.cs
  61. 3
      src/Squidex/Pipeline/Squid/SquidMiddleware.cs
  62. 3
      src/Squidex/Pipeline/Swagger/NSwagHelper.cs
  63. 1
      src/Squidex/WebStartup.cs
  64. 13
      tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleElementRegistryTests.cs
  65. 8
      tests/Squidex.Domain.Apps.Core.Tests/TestUtils.cs
  66. 41
      tests/Squidex.Infrastructure.Tests/TypeNameRegistryTests.cs
  67. 2
      tools/Migrate_01/SquidexMigrations.cs

1
extensions/Squidex.Extensions/Actions/Algolia/AlgoliaAction.cs

@ -11,7 +11,6 @@ using Squidex.Domain.Apps.Core.Rules;
namespace Squidex.Extensions.Actions.Algolia namespace Squidex.Extensions.Actions.Algolia
{ {
[RuleActionHandler(typeof(AlgoliaActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M16 .842C7.633.842.842 7.625.842 16S7.625 31.158 16 31.158c8.374 0 15.158-6.791 15.158-15.166S24.375.842 16 .842zm0 25.83c-5.898 0-10.68-4.781-10.68-10.68S10.101 5.313 16 5.313s10.68 4.781 10.68 10.679-4.781 10.68-10.68 10.68zm0-19.156v7.956c0 .233.249.388.458.279l7.055-3.663a.312.312 0 0 0 .124-.434 8.807 8.807 0 0 0-7.319-4.447z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M16 .842C7.633.842.842 7.625.842 16S7.625 31.158 16 31.158c8.374 0 15.158-6.791 15.158-15.166S24.375.842 16 .842zm0 25.83c-5.898 0-10.68-4.781-10.68-10.68S10.101 5.313 16 5.313s10.68 4.781 10.68 10.679-4.781 10.68-10.68 10.68zm0-19.156v7.956c0 .233.249.388.458.279l7.055-3.663a.312.312 0 0 0 .124-.434 8.807 8.807 0 0 0-7.319-4.447z'/></svg>",
IconColor = "#0d9bf9", IconColor = "#0d9bf9",

3
extensions/Squidex.Extensions/Actions/Algolia/AlgoliaPlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.Algolia namespace Squidex.Extensions.Actions.Algolia
@ -16,7 +15,7 @@ namespace Squidex.Extensions.Actions.Algolia
{ {
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{ {
RuleActionRegistry.Add<AlgoliaAction>(); services.AddRuleAction<AlgoliaAction, AlgoliaActionHandler>();
} }
} }
} }

1
extensions/Squidex.Extensions/Actions/AzureQueue/AzureQueueAction.cs

@ -14,7 +14,6 @@ using Squidex.Infrastructure;
namespace Squidex.Extensions.Actions.AzureQueue namespace Squidex.Extensions.Actions.AzureQueue
{ {
[RuleActionHandler(typeof(AzureQueueActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M.011 16L0 6.248l12-1.63V16zM14 4.328L29.996 2v14H14zM30 18l-.004 14L14 29.75V18zM12 29.495L.01 27.851.009 18H12z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M.011 16L0 6.248l12-1.63V16zM14 4.328L29.996 2v14H14zM30 18l-.004 14L14 29.75V18zM12 29.495L.01 27.851.009 18H12z'/></svg>",
IconColor = "#0d9bf9", IconColor = "#0d9bf9",

3
extensions/Squidex.Extensions/Actions/AzureQueue/AzureQueuePlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.AzureQueue namespace Squidex.Extensions.Actions.AzureQueue
@ -16,7 +15,7 @@ namespace Squidex.Extensions.Actions.AzureQueue
{ {
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{ {
RuleActionRegistry.Add<AzureQueueAction>(); services.AddRuleAction<AzureQueueAction, AzureQueueActionHandler>();
} }
} }
} }

1
extensions/Squidex.Extensions/Actions/Discourse/DiscourseAction.cs

@ -13,7 +13,6 @@ using Squidex.Infrastructure;
namespace Squidex.Extensions.Actions.Discourse namespace Squidex.Extensions.Actions.Discourse
{ {
[RuleActionHandler(typeof(DiscourseActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M16.137 0C7.376 0 0 7.037 0 15.721V32l16.134-.016C24.895 31.984 32 24.676 32 15.995S24.888 0 16.137 0zm.336 6.062a9.862 9.862 0 0 1 5.119 1.555l-.038-.023a.747.747 0 0 1 .05.033l-.033-.021c.288.183.529.353.762.534l-.022-.016c.058.044.094.073.131.103l-.018-.014c.218.174.411.34.597.514l-.005-.005a9.48 9.48 0 0 1 .639.655l.009.01c.073.082.154.176.233.272l.014.018c.053.06.116.133.177.206l.013.017-.052-.047-.008-.007c.104.126.218.273.328.423l.02.028.001.001-.001-.001c-.01-.018.005.005.019.028l.024.042c.145.206.301.451.445.704l.025.048c.131.226.273.51.402.801l.025.063a9.504 9.504 0 0 1 .802 3.853c0 5.38-4.401 9.741-9.831 9.741a9.866 9.866 0 0 1-4.106-.888l.061.025-6.39 1.43 1.78-5.672a7.888 7.888 0 0 1-.293-.584l-.025-.061a8.226 8.226 0 0 1-.254-.617l-.022-.068A1.043 1.043 0 0 1 7 19.017l-.022-.067a8.428 8.428 0 0 1-.246-.829l-.014-.067a9.402 9.402 0 0 1-.265-2.248c0-5.381 4.403-9.744 9.834-9.744l.194.002h-.01z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M16.137 0C7.376 0 0 7.037 0 15.721V32l16.134-.016C24.895 31.984 32 24.676 32 15.995S24.888 0 16.137 0zm.336 6.062a9.862 9.862 0 0 1 5.119 1.555l-.038-.023a.747.747 0 0 1 .05.033l-.033-.021c.288.183.529.353.762.534l-.022-.016c.058.044.094.073.131.103l-.018-.014c.218.174.411.34.597.514l-.005-.005a9.48 9.48 0 0 1 .639.655l.009.01c.073.082.154.176.233.272l.014.018c.053.06.116.133.177.206l.013.017-.052-.047-.008-.007c.104.126.218.273.328.423l.02.028.001.001-.001-.001c-.01-.018.005.005.019.028l.024.042c.145.206.301.451.445.704l.025.048c.131.226.273.51.402.801l.025.063a9.504 9.504 0 0 1 .802 3.853c0 5.38-4.401 9.741-9.831 9.741a9.866 9.866 0 0 1-4.106-.888l.061.025-6.39 1.43 1.78-5.672a7.888 7.888 0 0 1-.293-.584l-.025-.061a8.226 8.226 0 0 1-.254-.617l-.022-.068A1.043 1.043 0 0 1 7 19.017l-.022-.067a8.428 8.428 0 0 1-.246-.829l-.014-.067a9.402 9.402 0 0 1-.265-2.248c0-5.381 4.403-9.744 9.834-9.744l.194.002h-.01z'/></svg>",
IconColor = "#eB6121", IconColor = "#eB6121",

3
extensions/Squidex.Extensions/Actions/Discourse/DiscoursePlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.Discourse namespace Squidex.Extensions.Actions.Discourse
@ -16,7 +15,7 @@ namespace Squidex.Extensions.Actions.Discourse
{ {
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{ {
RuleActionRegistry.Add<DiscourseAction>(); services.AddRuleAction<DiscourseAction, DiscourseActionHandler>();
} }
} }
} }

1
extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchAction.cs

@ -13,7 +13,6 @@ using Squidex.Infrastructure;
namespace Squidex.Extensions.Actions.ElasticSearch namespace Squidex.Extensions.Actions.ElasticSearch
{ {
[RuleActionHandler(typeof(ElasticSearchActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 29 28'><path d='M13.427 17.436H4.163C3.827 16.354 3.636 15.2 3.636 14s.182-2.355.527-3.436h15.245c1.891 0 3.418 1.545 3.418 3.445a3.421 3.421 0 0 1-3.418 3.427h-5.982zm-.436 1.146H4.6a11.508 11.508 0 0 0 4.2 4.982 11.443 11.443 0 0 0 15.827-3.209 5.793 5.793 0 0 0-4.173-1.773H12.99zm7.464-9.164a5.794 5.794 0 0 0 4.173-1.773 11.45 11.45 0 0 0-9.536-5.1c-2.327 0-4.491.7-6.3 1.891a11.554 11.554 0 0 0-4.2 4.982h15.864z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 29 28'><path d='M13.427 17.436H4.163C3.827 16.354 3.636 15.2 3.636 14s.182-2.355.527-3.436h15.245c1.891 0 3.418 1.545 3.418 3.445a3.421 3.421 0 0 1-3.418 3.427h-5.982zm-.436 1.146H4.6a11.508 11.508 0 0 0 4.2 4.982 11.443 11.443 0 0 0 15.827-3.209 5.793 5.793 0 0 0-4.173-1.773H12.99zm7.464-9.164a5.794 5.794 0 0 0 4.173-1.773 11.45 11.45 0 0 0-9.536-5.1c-2.327 0-4.491.7-6.3 1.891a11.554 11.554 0 0 0-4.2 4.982h15.864z'/></svg>",
IconColor = "#1e5470", IconColor = "#1e5470",

3
extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchPlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.ElasticSearch namespace Squidex.Extensions.Actions.ElasticSearch
@ -16,7 +15,7 @@ namespace Squidex.Extensions.Actions.ElasticSearch
{ {
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{ {
RuleActionRegistry.Add<ElasticSearchAction>(); services.AddRuleAction<ElasticSearchAction, ElasticSearchActionHandler>();
} }
} }
} }

1
extensions/Squidex.Extensions/Actions/Email/EmailAction.cs

@ -11,7 +11,6 @@ using Squidex.Domain.Apps.Core.Rules;
namespace Squidex.Extensions.Actions.Email namespace Squidex.Extensions.Actions.Email
{ {
[RuleActionHandler(typeof(EmailActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M28 5h-24c-2.209 0-4 1.792-4 4v13c0 2.209 1.791 4 4 4h24c2.209 0 4-1.791 4-4v-13c0-2.208-1.791-4-4-4zM2 10.25l6.999 5.25-6.999 5.25v-10.5zM30 22c0 1.104-0.898 2-2 2h-24c-1.103 0-2-0.896-2-2l7.832-5.875 4.368 3.277c0.533 0.398 1.166 0.6 1.8 0.6 0.633 0 1.266-0.201 1.799-0.6l4.369-3.277 7.832 5.875zM30 20.75l-7-5.25 7-5.25v10.5zM17.199 18.602c-0.349 0.262-0.763 0.4-1.199 0.4s-0.851-0.139-1.2-0.4l-12.8-9.602c0-1.103 0.897-2 2-2h24c1.102 0 2 0.897 2 2l-12.801 9.602z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M28 5h-24c-2.209 0-4 1.792-4 4v13c0 2.209 1.791 4 4 4h24c2.209 0 4-1.791 4-4v-13c0-2.208-1.791-4-4-4zM2 10.25l6.999 5.25-6.999 5.25v-10.5zM30 22c0 1.104-0.898 2-2 2h-24c-1.103 0-2-0.896-2-2l7.832-5.875 4.368 3.277c0.533 0.398 1.166 0.6 1.8 0.6 0.633 0 1.266-0.201 1.799-0.6l4.369-3.277 7.832 5.875zM30 20.75l-7-5.25 7-5.25v10.5zM17.199 18.602c-0.349 0.262-0.763 0.4-1.199 0.4s-0.851-0.139-1.2-0.4l-12.8-9.602c0-1.103 0.897-2 2-2h24c1.102 0 2 0.897 2 2l-12.801 9.602z'/></svg>",
IconColor = "#333300", IconColor = "#333300",

3
extensions/Squidex.Extensions/Actions/Email/EmailPlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.Email namespace Squidex.Extensions.Actions.Email
@ -16,7 +15,7 @@ namespace Squidex.Extensions.Actions.Email
{ {
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{ {
RuleActionRegistry.Add<EmailAction>(); services.AddRuleAction<EmailAction, EmailActionHandler>();
} }
} }
} }

1
extensions/Squidex.Extensions/Actions/Fastly/FastlyAction.cs

@ -11,7 +11,6 @@ using Squidex.Domain.Apps.Core.Rules;
namespace Squidex.Extensions.Actions.Fastly namespace Squidex.Extensions.Actions.Fastly
{ {
[RuleActionHandler(typeof(FastlyActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 32'><path d='M10.68.948v1.736h.806v2.6A12.992 12.992 0 0 0 .951 18.051c0 7.178 5.775 12.996 12.9 12.996 7.124 0 12.9-5.819 12.9-12.996-.004-6.332-4.502-11.605-10.455-12.755l-.081-.013V2.684h.807V.948H10.68zm3.53 10.605c3.218.173 5.81 2.713 6.09 5.922v.211h-.734v.737h.734v.201c-.279 3.21-2.871 5.752-6.09 5.925v-.723h-.733v.721c-3.281-.192-5.905-2.845-6.077-6.152h.728v-.737h-.724c.195-3.284 2.808-5.911 6.073-6.103v.725h.733v-.727zm2.513 3.051l-2.462 2.282a1.13 1.13 0 0 0-.41-.078c-.633 0-1.147.517-1.147 1.155a1.15 1.15 0 0 0 1.147 1.155c.633 0 1.147-.517 1.147-1.155 0-.117-.018-.23-.05-.337l.002.008 2.223-2.505-.449-.526z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 32'><path d='M10.68.948v1.736h.806v2.6A12.992 12.992 0 0 0 .951 18.051c0 7.178 5.775 12.996 12.9 12.996 7.124 0 12.9-5.819 12.9-12.996-.004-6.332-4.502-11.605-10.455-12.755l-.081-.013V2.684h.807V.948H10.68zm3.53 10.605c3.218.173 5.81 2.713 6.09 5.922v.211h-.734v.737h.734v.201c-.279 3.21-2.871 5.752-6.09 5.925v-.723h-.733v.721c-3.281-.192-5.905-2.845-6.077-6.152h.728v-.737h-.724c.195-3.284 2.808-5.911 6.073-6.103v.725h.733v-.727zm2.513 3.051l-2.462 2.282a1.13 1.13 0 0 0-.41-.078c-.633 0-1.147.517-1.147 1.155a1.15 1.15 0 0 0 1.147 1.155c.633 0 1.147-.517 1.147-1.155 0-.117-.018-.23-.05-.337l.002.008 2.223-2.505-.449-.526z'/></svg>",
IconColor = "#e23335", IconColor = "#e23335",

3
extensions/Squidex.Extensions/Actions/Fastly/FastlyPlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.Fastly namespace Squidex.Extensions.Actions.Fastly
@ -16,7 +15,7 @@ namespace Squidex.Extensions.Actions.Fastly
{ {
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{ {
RuleActionRegistry.Add<FastlyAction>(); services.AddRuleAction<FastlyAction, FastlyActionHandler>();
} }
} }
} }

1
extensions/Squidex.Extensions/Actions/Medium/MediumAction.cs

@ -11,7 +11,6 @@ using Squidex.Domain.Apps.Core.Rules;
namespace Squidex.Extensions.Actions.Medium namespace Squidex.Extensions.Actions.Medium
{ {
[RuleActionHandler(typeof(MediumActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M3.795 8.48a1.239 1.239 0 0 0-.404-1.045l-2.987-3.6v-.537H9.68l7.171 15.727 6.304-15.727H32v.537l-2.556 2.449a.749.749 0 0 0-.284.717v18a.749.749 0 0 0 .284.716l2.493 2.449v.537H19.39v-.537l2.583-2.509c.253-.253.253-.328.253-.717V10.392l-7.187 18.251h-.969L5.703 10.392v12.232a1.69 1.69 0 0 0 .463 1.404l3.36 4.08v.536H-.001v-.537l3.36-4.08c.36-.371.52-.893.435-1.403V8.48z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M3.795 8.48a1.239 1.239 0 0 0-.404-1.045l-2.987-3.6v-.537H9.68l7.171 15.727 6.304-15.727H32v.537l-2.556 2.449a.749.749 0 0 0-.284.717v18a.749.749 0 0 0 .284.716l2.493 2.449v.537H19.39v-.537l2.583-2.509c.253-.253.253-.328.253-.717V10.392l-7.187 18.251h-.969L5.703 10.392v12.232a1.69 1.69 0 0 0 .463 1.404l3.36 4.08v.536H-.001v-.537l3.36-4.08c.36-.371.52-.893.435-1.403V8.48z'/></svg>",
IconColor = "#00ab6c", IconColor = "#00ab6c",

3
extensions/Squidex.Extensions/Actions/Medium/MediumPlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.Medium namespace Squidex.Extensions.Actions.Medium
@ -16,7 +15,7 @@ namespace Squidex.Extensions.Actions.Medium
{ {
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{ {
RuleActionRegistry.Add<MediumAction>(); services.AddRuleAction<MediumAction, MediumActionHandler>();
} }
} }
} }

1
extensions/Squidex.Extensions/Actions/Prerender/PrerenderAction.cs

@ -11,7 +11,6 @@ using Squidex.Domain.Apps.Core.Rules;
namespace Squidex.Extensions.Actions.Prerender namespace Squidex.Extensions.Actions.Prerender
{ {
[RuleActionHandler(typeof(PrerenderActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M2.073 17.984l8.646-5.36v-1.787L.356 17.325v1.318l10.363 6.488v-1.787zM29.927 17.984l-8.646-5.36v-1.787l10.363 6.488v1.318l-10.363 6.488v-1.787zM18.228 6.693l-6.276 19.426 1.656.548 6.276-19.426z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M2.073 17.984l8.646-5.36v-1.787L.356 17.325v1.318l10.363 6.488v-1.787zM29.927 17.984l-8.646-5.36v-1.787l10.363 6.488v1.318l-10.363 6.488v-1.787zM18.228 6.693l-6.276 19.426 1.656.548 6.276-19.426z'/></svg>",
IconColor = "#2c3e50", IconColor = "#2c3e50",

3
extensions/Squidex.Extensions/Actions/Prerender/PrerenderPlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.Prerender namespace Squidex.Extensions.Actions.Prerender
@ -16,7 +15,7 @@ namespace Squidex.Extensions.Actions.Prerender
{ {
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{ {
RuleActionRegistry.Add<PrerenderAction>(); services.AddRuleAction<PrerenderAction, PrerenderActionHandler>();
} }
} }
} }

1
extensions/Squidex.Extensions/Actions/Slack/SlackAction.cs

@ -13,7 +13,6 @@ using Squidex.Infrastructure;
namespace Squidex.Extensions.Actions.Slack namespace Squidex.Extensions.Actions.Slack
{ {
[RuleActionHandler(typeof(SlackActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 28'><path d='M23.734 12.125c1.281 0 2.266.938 2.266 2.219 0 1-.516 1.703-1.453 2.031l-2.688.922.875 2.609c.078.234.109.484.109.734 0 1.234-1 2.266-2.234 2.266a2.271 2.271 0 0 1-2.172-1.547l-.859-2.578-4.844 1.656.859 2.562c.078.234.125.484.125.734 0 1.219-1 2.266-2.25 2.266a2.25 2.25 0 0 1-2.156-1.547l-.859-2.547-2.391.828c-.25.078-.516.141-.781.141-1.266 0-2.219-.938-2.219-2.203 0-.969.625-1.844 1.547-2.156l2.438-.828-1.641-4.891-2.438.844c-.25.078-.5.125-.75.125-1.25 0-2.219-.953-2.219-2.203 0-.969.625-1.844 1.547-2.156l2.453-.828-.828-2.484a2.337 2.337 0 0 1-.125-.734c0-1.234 1-2.266 2.25-2.266a2.25 2.25 0 0 1 2.156 1.547l.844 2.5L13.14 5.5 12.296 3a2.337 2.337 0 0 1-.125-.734c0-1.234 1.016-2.266 2.25-2.266.984 0 1.859.625 2.172 1.547l.828 2.516 2.531-.859c.219-.063.438-.094.672-.094 1.219 0 2.266.906 2.266 2.156 0 .969-.75 1.781-1.625 2.078l-2.453.844 1.641 4.937 2.562-.875a2.32 2.32 0 0 1 .719-.125zm-12.406 4.094l4.844-1.641-1.641-4.922-4.844 1.672z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 28'><path d='M23.734 12.125c1.281 0 2.266.938 2.266 2.219 0 1-.516 1.703-1.453 2.031l-2.688.922.875 2.609c.078.234.109.484.109.734 0 1.234-1 2.266-2.234 2.266a2.271 2.271 0 0 1-2.172-1.547l-.859-2.578-4.844 1.656.859 2.562c.078.234.125.484.125.734 0 1.219-1 2.266-2.25 2.266a2.25 2.25 0 0 1-2.156-1.547l-.859-2.547-2.391.828c-.25.078-.516.141-.781.141-1.266 0-2.219-.938-2.219-2.203 0-.969.625-1.844 1.547-2.156l2.438-.828-1.641-4.891-2.438.844c-.25.078-.5.125-.75.125-1.25 0-2.219-.953-2.219-2.203 0-.969.625-1.844 1.547-2.156l2.453-.828-.828-2.484a2.337 2.337 0 0 1-.125-.734c0-1.234 1-2.266 2.25-2.266a2.25 2.25 0 0 1 2.156 1.547l.844 2.5L13.14 5.5 12.296 3a2.337 2.337 0 0 1-.125-.734c0-1.234 1.016-2.266 2.25-2.266.984 0 1.859.625 2.172 1.547l.828 2.516 2.531-.859c.219-.063.438-.094.672-.094 1.219 0 2.266.906 2.266 2.156 0 .969-.75 1.781-1.625 2.078l-2.453.844 1.641 4.937 2.562-.875a2.32 2.32 0 0 1 .719-.125zm-12.406 4.094l4.844-1.641-1.641-4.922-4.844 1.672z'/></svg>",
IconColor = "#5c3a58", IconColor = "#5c3a58",

3
extensions/Squidex.Extensions/Actions/Slack/SlackPlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.Slack namespace Squidex.Extensions.Actions.Slack
@ -16,7 +15,7 @@ namespace Squidex.Extensions.Actions.Slack
{ {
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{ {
RuleActionRegistry.Add<SlackAction>(); services.AddRuleAction<SlackAction, SlackActionHandler>();
} }
} }
} }

1
extensions/Squidex.Extensions/Actions/Twitter/TweetAction.cs

@ -11,7 +11,6 @@ using Squidex.Domain.Apps.Core.Rules;
namespace Squidex.Extensions.Actions.Twitter namespace Squidex.Extensions.Actions.Twitter
{ {
[RuleActionHandler(typeof(TweetActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M32 7.075a12.941 12.941 0 0 1-3.769 1.031 6.601 6.601 0 0 0 2.887-3.631 13.21 13.21 0 0 1-4.169 1.594A6.565 6.565 0 0 0 22.155 4a6.563 6.563 0 0 0-6.563 6.563c0 .512.056 1.012.169 1.494A18.635 18.635 0 0 1 2.23 5.195a6.56 6.56 0 0 0-.887 3.3 6.557 6.557 0 0 0 2.919 5.463 6.565 6.565 0 0 1-2.975-.819v.081a6.565 6.565 0 0 0 5.269 6.437 6.574 6.574 0 0 1-2.968.112 6.588 6.588 0 0 0 6.131 4.563 13.17 13.17 0 0 1-9.725 2.719 18.568 18.568 0 0 0 10.069 2.95c12.075 0 18.681-10.006 18.681-18.681 0-.287-.006-.569-.019-.85A13.216 13.216 0 0 0 32 7.076z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M32 7.075a12.941 12.941 0 0 1-3.769 1.031 6.601 6.601 0 0 0 2.887-3.631 13.21 13.21 0 0 1-4.169 1.594A6.565 6.565 0 0 0 22.155 4a6.563 6.563 0 0 0-6.563 6.563c0 .512.056 1.012.169 1.494A18.635 18.635 0 0 1 2.23 5.195a6.56 6.56 0 0 0-.887 3.3 6.557 6.557 0 0 0 2.919 5.463 6.565 6.565 0 0 1-2.975-.819v.081a6.565 6.565 0 0 0 5.269 6.437 6.574 6.574 0 0 1-2.968.112 6.588 6.588 0 0 0 6.131 4.563 13.17 13.17 0 0 1-9.725 2.719 18.568 18.568 0 0 0 10.069 2.95c12.075 0 18.681-10.006 18.681-18.681 0-.287-.006-.569-.019-.85A13.216 13.216 0 0 0 32 7.076z'/></svg>",
IconColor = "#1da1f2", IconColor = "#1da1f2",

3
extensions/Squidex.Extensions/Actions/Twitter/TwitterPlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.Twitter namespace Squidex.Extensions.Actions.Twitter
@ -19,7 +18,7 @@ namespace Squidex.Extensions.Actions.Twitter
services.Configure<TwitterOptions>( services.Configure<TwitterOptions>(
configuration.GetSection("twitter")); configuration.GetSection("twitter"));
RuleActionRegistry.Add<TweetAction>(); services.AddRuleAction<TweetAction, TweetActionHandler>();
} }
} }
} }

1
extensions/Squidex.Extensions/Actions/Webhook/WebhookAction.cs

@ -13,7 +13,6 @@ using Squidex.Infrastructure;
namespace Squidex.Extensions.Actions.Webhook namespace Squidex.Extensions.Actions.Webhook
{ {
[RuleActionHandler(typeof(WebhookActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28'><path d='M5.95 27.125h-.262C1.75 26.425 0 23.187 0 20.3c0-2.713 1.575-5.688 5.075-6.563V9.712c0-.525.35-.875.875-.875s.875.35.875.875v4.725c0 .438-.35.787-.7.875-2.975.438-4.375 2.8-4.375 4.988s1.313 4.55 4.2 5.075h.175a.907.907 0 0 1 .7 1.05c-.088.438-.438.7-.875.7zM21.175 27.387c-2.8 0-5.775-1.662-6.65-5.075H9.712c-.525 0-.875-.35-.875-.875s.35-.875.875-.875h5.512c.438 0 .787.35.875.7.438 2.975 2.8 4.288 4.988 4.375 2.188 0 4.55-1.313 5.075-4.2v-.088a.908.908 0 0 1 1.05-.7.908.908 0 0 1 .7 1.05v.088c-.612 3.85-3.85 5.6-6.737 5.6zM21.525 18.55c-.525 0-.875-.35-.875-.875v-4.813c0-.438.35-.787.7-.875 2.975-.438 4.288-2.8 4.375-4.987 0-2.188-1.313-4.55-4.2-5.075h-.088c-.525-.175-.875-.613-.787-1.05s.525-.788 1.05-.7h.088c3.938.7 5.688 3.937 5.688 6.825 0 2.713-1.662 5.688-5.075 6.563v4.113c0 .438-.438.875-.875.875zM1.137 6.737H.962c-.438-.087-.788-.525-.7-.963v-.087c.7-3.938 3.85-5.688 6.737-5.688h.087c2.712 0 5.688 1.662 6.563 5.075h4.025c.525 0 .875.35.875.875s-.35.875-.875.875h-4.725c-.438 0-.788-.35-.875-.7-.438-2.975-2.8-4.288-4.988-4.375-2.188 0-4.55 1.313-5.075 4.2v.087c-.088.438-.438.7-.875.7z'/><path d='M7 10.588c-.875 0-1.837-.35-2.538-1.05a3.591 3.591 0 0 1 0-5.075C5.162 3.851 6.037 3.5 7 3.5s1.838.35 2.537 1.05c.7.7 1.05 1.575 1.05 2.537s-.35 1.837-1.05 2.538c-.7.612-1.575.963-2.537.963zM7 5.25c-.438 0-.875.175-1.225.525a1.795 1.795 0 0 0 2.538 2.538c.35-.35.525-.788.525-1.313s-.175-.875-.525-1.225S7.525 5.25 7 5.25zM21.088 23.887a3.65 3.65 0 0 1-2.537-1.05 3.591 3.591 0 0 1 0-5.075c.7-.7 1.575-1.05 2.537-1.05s1.838.35 2.537 1.05c.7.7 1.05 1.575 1.05 2.538s-.35 1.837-1.05 2.537c-.787.7-1.662 1.05-2.537 1.05zm0-5.337c-.525 0-.963.175-1.313.525a1.795 1.795 0 0 0 2.537 2.538c.35-.35.525-.788.525-1.313s-.175-.963-.525-1.313-.787-.438-1.225-.438zM20.387 10.588c-.875 0-1.837-.35-2.537-1.05S16.8 7.963 16.8 7.001s.35-1.837 1.05-2.538c.7-.612 1.662-.962 2.537-.962s1.838.35 2.538 1.05c1.4 1.4 1.4 3.675 0 5.075-.7.612-1.575.963-2.538.963zm0-5.338c-.525 0-.962.175-1.313.525s-.525.788-.525 1.313.175.962.525 1.313c.7.7 1.838.7 2.538 0s.7-1.838 0-2.538c-.263-.438-.7-.612-1.225-.612zM7.087 23.887c-.875 0-1.837-.35-2.538-1.05s-1.05-1.575-1.05-2.537.35-1.838 1.05-2.538c.7-.612 1.575-.962 2.538-.962s1.837.35 2.538 1.05c1.4 1.4 1.4 3.675 0 5.075-.7.612-1.575.962-2.538.962zm0-5.337c-.525 0-.962.175-1.313.525s-.525.788-.525 1.313.175.963.525 1.313a1.794 1.794 0 1 0 2.538-2.537c-.263-.438-.7-.612-1.225-.612z'/></svg>", IconImage = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28'><path d='M5.95 27.125h-.262C1.75 26.425 0 23.187 0 20.3c0-2.713 1.575-5.688 5.075-6.563V9.712c0-.525.35-.875.875-.875s.875.35.875.875v4.725c0 .438-.35.787-.7.875-2.975.438-4.375 2.8-4.375 4.988s1.313 4.55 4.2 5.075h.175a.907.907 0 0 1 .7 1.05c-.088.438-.438.7-.875.7zM21.175 27.387c-2.8 0-5.775-1.662-6.65-5.075H9.712c-.525 0-.875-.35-.875-.875s.35-.875.875-.875h5.512c.438 0 .787.35.875.7.438 2.975 2.8 4.288 4.988 4.375 2.188 0 4.55-1.313 5.075-4.2v-.088a.908.908 0 0 1 1.05-.7.908.908 0 0 1 .7 1.05v.088c-.612 3.85-3.85 5.6-6.737 5.6zM21.525 18.55c-.525 0-.875-.35-.875-.875v-4.813c0-.438.35-.787.7-.875 2.975-.438 4.288-2.8 4.375-4.987 0-2.188-1.313-4.55-4.2-5.075h-.088c-.525-.175-.875-.613-.787-1.05s.525-.788 1.05-.7h.088c3.938.7 5.688 3.937 5.688 6.825 0 2.713-1.662 5.688-5.075 6.563v4.113c0 .438-.438.875-.875.875zM1.137 6.737H.962c-.438-.087-.788-.525-.7-.963v-.087c.7-3.938 3.85-5.688 6.737-5.688h.087c2.712 0 5.688 1.662 6.563 5.075h4.025c.525 0 .875.35.875.875s-.35.875-.875.875h-4.725c-.438 0-.788-.35-.875-.7-.438-2.975-2.8-4.288-4.988-4.375-2.188 0-4.55 1.313-5.075 4.2v.087c-.088.438-.438.7-.875.7z'/><path d='M7 10.588c-.875 0-1.837-.35-2.538-1.05a3.591 3.591 0 0 1 0-5.075C5.162 3.851 6.037 3.5 7 3.5s1.838.35 2.537 1.05c.7.7 1.05 1.575 1.05 2.537s-.35 1.837-1.05 2.538c-.7.612-1.575.963-2.537.963zM7 5.25c-.438 0-.875.175-1.225.525a1.795 1.795 0 0 0 2.538 2.538c.35-.35.525-.788.525-1.313s-.175-.875-.525-1.225S7.525 5.25 7 5.25zM21.088 23.887a3.65 3.65 0 0 1-2.537-1.05 3.591 3.591 0 0 1 0-5.075c.7-.7 1.575-1.05 2.537-1.05s1.838.35 2.537 1.05c.7.7 1.05 1.575 1.05 2.538s-.35 1.837-1.05 2.537c-.787.7-1.662 1.05-2.537 1.05zm0-5.337c-.525 0-.963.175-1.313.525a1.795 1.795 0 0 0 2.537 2.538c.35-.35.525-.788.525-1.313s-.175-.963-.525-1.313-.787-.438-1.225-.438zM20.387 10.588c-.875 0-1.837-.35-2.537-1.05S16.8 7.963 16.8 7.001s.35-1.837 1.05-2.538c.7-.612 1.662-.962 2.537-.962s1.838.35 2.538 1.05c1.4 1.4 1.4 3.675 0 5.075-.7.612-1.575.963-2.538.963zm0-5.338c-.525 0-.962.175-1.313.525s-.525.788-.525 1.313.175.962.525 1.313c.7.7 1.838.7 2.538 0s.7-1.838 0-2.538c-.263-.438-.7-.612-1.225-.612zM7.087 23.887c-.875 0-1.837-.35-2.538-1.05s-1.05-1.575-1.05-2.537.35-1.838 1.05-2.538c.7-.612 1.575-.962 2.538-.962s1.837.35 2.538 1.05c1.4 1.4 1.4 3.675 0 5.075-.7.612-1.575.962-2.538.962zm0-5.337c-.525 0-.962.175-1.313.525s-.525.788-.525 1.313.175.963.525 1.313a1.794 1.794 0 1 0 2.538-2.537c-.263-.438-.7-.612-1.225-.612z'/></svg>",
IconColor = "#4bb958", IconColor = "#4bb958",

3
extensions/Squidex.Extensions/Actions/Webhook/WebhookPlugin.cs

@ -7,7 +7,6 @@
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure.Plugins; using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Actions.Webhook namespace Squidex.Extensions.Actions.Webhook
@ -16,7 +15,7 @@ namespace Squidex.Extensions.Actions.Webhook
{ {
public void ConfigureServices(IServiceCollection services, IConfiguration configuration) public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{ {
RuleActionRegistry.Add<WebhookAction>(); services.AddRuleAction<WebhookAction, WebhookActionHandler>();
} }
} }
} }

6
src/Squidex.Domain.Apps.Core.Model/Schemas/FieldRegistry.cs

@ -12,12 +12,12 @@ using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Core.Schemas namespace Squidex.Domain.Apps.Core.Schemas
{ {
public static class FieldRegistry public class FieldRegistry : ITypeProvider
{ {
private const string Suffix = "Properties"; private const string Suffix = "Properties";
private const string SuffixOld = "FieldProperties"; private const string SuffixOld = "FieldProperties";
public static TypeNameRegistry MapFields(this TypeNameRegistry typeNameRegistry) public void Map(TypeNameRegistry typeNameRegistry)
{ {
var types = typeof(FieldRegistry).Assembly.GetTypes().Where(x => typeof(FieldProperties).IsAssignableFrom(x) && !x.IsAbstract); var types = typeof(FieldRegistry).Assembly.GetTypes().Where(x => typeof(FieldProperties).IsAssignableFrom(x) && !x.IsAbstract);
@ -32,8 +32,6 @@ namespace Squidex.Domain.Apps.Core.Schemas
typeNameRegistry.MapObsolete(type, type.TypeName(false, SuffixOld)); typeNameRegistry.MapObsolete(type, type.TypeName(false, SuffixOld));
} }
} }
return typeNameRegistry;
} }
} }
} }

2
src/Squidex.Domain.Apps.Core.Model/SquidexCoreModel.cs

@ -9,7 +9,7 @@ using System.Reflection;
namespace Squidex.Domain.Apps.Core namespace Squidex.Domain.Apps.Core
{ {
public static class SquidexCoreModel public sealed class SquidexCoreModel
{ {
public static readonly Assembly Assembly = typeof(SquidexCoreModel).Assembly; public static readonly Assembly Assembly = typeof(SquidexCoreModel).Assembly;
} }

25
src/Squidex.Domain.Apps.Core.Operations/HandleRules/DependencyInjectionExtensions.cs

@ -0,0 +1,25 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Domain.Apps.Core.Rules;
namespace Microsoft.Extensions.DependencyInjection
{
public static class DependencyInjectionExtensions
{
public static IServiceCollection AddRuleAction<TAction, THandler>(this IServiceCollection services) where THandler : class, IRuleActionHandler where TAction : RuleAction
{
services.AddSingletonAs<THandler>()
.As<IRuleActionHandler>();
services.AddSingleton(new RuleActionRegistration(typeof(TAction)));
return services;
}
}
}

30
src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionHandlerAttribute.cs

@ -1,30 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Core.HandleRules
{
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class RuleActionHandlerAttribute : Attribute
{
public Type HandlerType { get; }
public RuleActionHandlerAttribute(Type handlerType)
{
Guard.NotNull(handlerType, nameof(handlerType));
HandlerType = handlerType;
if (!typeof(IRuleActionHandler).IsAssignableFrom(handlerType))
{
throw new ArgumentException($"Handler type must implement {typeof(IRuleActionHandler)}.", nameof(handlerType));
}
}
}
}

24
src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionRegistration.cs

@ -0,0 +1,24 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Core.HandleRules
{
public sealed class RuleActionRegistration
{
public Type ActionType { get; }
internal RuleActionRegistration(Type actionType)
{
Guard.NotNull(actionType, nameof(actionType));
ActionType = actionType;
}
}
}

175
src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleActionRegistry.cs

@ -1,175 +0,0 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using Squidex.Domain.Apps.Core.Rules;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Core.HandleRules
{
public static class RuleActionRegistry
{
private const string ActionSuffix = "Action";
private const string ActionSuffixV2 = "ActionV2";
private static readonly HashSet<Type> ActionHandlerTypes = new HashSet<Type>();
private static readonly Dictionary<string, RuleActionDefinition> ActionTypes = new Dictionary<string, RuleActionDefinition>();
public static IReadOnlyDictionary<string, RuleActionDefinition> Actions
{
get { return ActionTypes; }
}
public static IReadOnlyCollection<Type> ActionHandlers
{
get { return ActionHandlerTypes; }
}
static RuleActionRegistry()
{
var actionTypes =
typeof(RuleActionRegistry).Assembly
.GetTypes()
.Where(x => typeof(RuleAction).IsAssignableFrom(x))
.Where(x => x.GetCustomAttribute<RuleActionAttribute>() != null)
.Where(x => x.GetCustomAttribute<RuleActionHandlerAttribute>() != null)
.ToList();
foreach (var actionType in actionTypes)
{
Add(actionType);
}
}
public static void Add<T>() where T : RuleAction
{
Add(typeof(T));
}
private static void Add(Type actionType)
{
var metadata = actionType.GetCustomAttribute<RuleActionAttribute>();
if (metadata == null)
{
return;
}
var handlerAttribute = actionType.GetCustomAttribute<RuleActionHandlerAttribute>();
if (handlerAttribute == null)
{
return;
}
var name = GetActionName(actionType);
var definition =
new RuleActionDefinition
{
Type = actionType,
Display = metadata.Display,
Description = metadata.Description,
IconColor = metadata.IconColor,
IconImage = metadata.IconImage,
ReadMore = metadata.ReadMore
};
foreach (var property in actionType.GetProperties())
{
if (property.CanRead && property.CanWrite)
{
var actionProperty = new RuleActionProperty { Name = property.Name.ToCamelCase(), Display = property.Name };
var display = property.GetCustomAttribute<DisplayAttribute>();
if (!string.IsNullOrWhiteSpace(display?.Name))
{
actionProperty.Display = display.Name;
}
if (!string.IsNullOrWhiteSpace(display?.Description))
{
actionProperty.Description = display.Description;
}
var type = property.PropertyType;
if ((property.GetCustomAttribute<RequiredAttribute>() != null || (type.IsValueType && !IsNullable(type))) && type != typeof(bool) && type != typeof(bool?))
{
actionProperty.IsRequired = true;
}
if (property.GetCustomAttribute<FormattableAttribute>() != null)
{
actionProperty.IsFormattable = true;
}
var dataType = property.GetCustomAttribute<DataTypeAttribute>()?.DataType;
if (type == typeof(bool) || type == typeof(bool?))
{
actionProperty.Editor = RuleActionPropertyEditor.Checkbox;
}
else if (type == typeof(int) || type == typeof(int?))
{
actionProperty.Editor = RuleActionPropertyEditor.Number;
}
else if (dataType == DataType.Url)
{
actionProperty.Editor = RuleActionPropertyEditor.Url;
}
else if (dataType == DataType.Password)
{
actionProperty.Editor = RuleActionPropertyEditor.Password;
}
else if (dataType == DataType.EmailAddress)
{
actionProperty.Editor = RuleActionPropertyEditor.Email;
}
else if (dataType == DataType.MultilineText)
{
actionProperty.Editor = RuleActionPropertyEditor.TextArea;
}
else
{
actionProperty.Editor = RuleActionPropertyEditor.Text;
}
definition.Properties.Add(actionProperty);
}
}
ActionTypes[name] = definition;
ActionHandlerTypes.Add(actionType.GetCustomAttribute<RuleActionHandlerAttribute>().HandlerType);
}
private static bool IsNullable(Type type)
{
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
}
public static TypeNameRegistry MapRuleActions(this TypeNameRegistry typeNameRegistry)
{
foreach (var actionType in ActionTypes.Values)
{
typeNameRegistry.Map(actionType.Type, actionType.Type.Name);
}
return typeNameRegistry;
}
private static string GetActionName(Type type)
{
return type.TypeName(false, ActionSuffix, ActionSuffixV2);
}
}
}

140
src/Squidex.Domain.Apps.Core.Operations/HandleRules/RuleRegistry.cs

@ -7,17 +7,151 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Reflection;
using Squidex.Domain.Apps.Core.HandleRules.EnrichedEvents; using Squidex.Domain.Apps.Core.HandleRules.EnrichedEvents;
using Squidex.Domain.Apps.Core.Rules; using Squidex.Domain.Apps.Core.Rules;
using Squidex.Infrastructure; using Squidex.Infrastructure;
#pragma warning disable RECS0033 // Convert 'if' to '||' expression
namespace Squidex.Domain.Apps.Core.HandleRules namespace Squidex.Domain.Apps.Core.HandleRules
{ {
public static class RuleRegistry public sealed class RuleRegistry : ITypeProvider
{ {
public static TypeNameRegistry MapRules(this TypeNameRegistry typeNameRegistry) private const string ActionSuffix = "Action";
private const string ActionSuffixV2 = "ActionV2";
private readonly Dictionary<string, RuleActionDefinition> actionTypes = new Dictionary<string, RuleActionDefinition>();
public IReadOnlyDictionary<string, RuleActionDefinition> Actions
{ {
get { return actionTypes; }
}
public RuleRegistry(IEnumerable<RuleActionRegistration> registrations = null)
{
if (registrations != null)
{
foreach (var registration in registrations)
{
Add(registration.ActionType);
}
}
}
public void Add<T>() where T : RuleAction
{
Add(typeof(T));
}
private void Add(Type actionType)
{
var metadata = actionType.GetCustomAttribute<RuleActionAttribute>();
if (metadata == null)
{
return;
}
var name = GetActionName(actionType);
var definition =
new RuleActionDefinition
{
Type = actionType,
Display = metadata.Display,
Description = metadata.Description,
IconColor = metadata.IconColor,
IconImage = metadata.IconImage,
ReadMore = metadata.ReadMore
};
foreach (var property in actionType.GetProperties())
{
if (property.CanRead && property.CanWrite)
{
var actionProperty = new RuleActionProperty { Name = property.Name.ToCamelCase(), Display = property.Name };
var display = property.GetCustomAttribute<DisplayAttribute>();
if (!string.IsNullOrWhiteSpace(display?.Name))
{
actionProperty.Display = display.Name;
}
if (!string.IsNullOrWhiteSpace(display?.Description))
{
actionProperty.Description = display.Description;
}
var type = property.PropertyType;
if ((property.GetCustomAttribute<RequiredAttribute>() != null || (type.IsValueType && !IsNullable(type))) && type != typeof(bool) && type != typeof(bool?))
{
actionProperty.IsRequired = true;
}
if (property.GetCustomAttribute<FormattableAttribute>() != null)
{
actionProperty.IsFormattable = true;
}
var dataType = property.GetCustomAttribute<DataTypeAttribute>()?.DataType;
if (type == typeof(bool) || type == typeof(bool?))
{
actionProperty.Editor = RuleActionPropertyEditor.Checkbox;
}
else if (type == typeof(int) || type == typeof(int?))
{
actionProperty.Editor = RuleActionPropertyEditor.Number;
}
else if (dataType == DataType.Url)
{
actionProperty.Editor = RuleActionPropertyEditor.Url;
}
else if (dataType == DataType.Password)
{
actionProperty.Editor = RuleActionPropertyEditor.Password;
}
else if (dataType == DataType.EmailAddress)
{
actionProperty.Editor = RuleActionPropertyEditor.Email;
}
else if (dataType == DataType.MultilineText)
{
actionProperty.Editor = RuleActionPropertyEditor.TextArea;
}
else
{
actionProperty.Editor = RuleActionPropertyEditor.Text;
}
definition.Properties.Add(actionProperty);
}
}
actionTypes[name] = definition;
}
private static bool IsNullable(Type type)
{
return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
}
private static string GetActionName(Type type)
{
return type.TypeName(false, ActionSuffix, ActionSuffixV2);
}
public void Map(TypeNameRegistry typeNameRegistry)
{
foreach (var actionType in actionTypes.Values)
{
typeNameRegistry.Map(actionType.Type, actionType.Type.Name);
}
var eventTypes = typeof(EnrichedEvent).Assembly.GetTypes().Where(x => typeof(EnrichedEvent).IsAssignableFrom(x) && !x.IsAbstract); var eventTypes = typeof(EnrichedEvent).Assembly.GetTypes().Where(x => typeof(EnrichedEvent).IsAssignableFrom(x) && !x.IsAbstract);
var addedTypes = new HashSet<Type>(); var addedTypes = new HashSet<Type>();
@ -39,8 +173,6 @@ namespace Squidex.Domain.Apps.Core.HandleRules
typeNameRegistry.Map(type, type.Name); typeNameRegistry.Map(type, type.Name);
} }
} }
return typeNameRegistry;
} }
} }
} }

2
src/Squidex.Domain.Apps.Events/SquidexEvents.cs

@ -9,7 +9,7 @@ using System.Reflection;
namespace Squidex.Domain.Apps.Events namespace Squidex.Domain.Apps.Events
{ {
public static class SquidexEvents public sealed class SquidexEvents
{ {
public static readonly Assembly Assembly = typeof(SquidexEvents).Assembly; public static readonly Assembly Assembly = typeof(SquidexEvents).Assembly;
} }

9
src/Squidex.Infrastructure.MongoDb/States/MongoSnapshotStore.cs

@ -5,10 +5,12 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Bson; using MongoDB.Bson;
using MongoDB.Driver; using MongoDB.Driver;
using Newtonsoft.Json;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;
@ -16,9 +18,12 @@ namespace Squidex.Infrastructure.States
{ {
public class MongoSnapshotStore<T, TKey> : MongoRepositoryBase<MongoState<T, TKey>>, ISnapshotStore<T, TKey> public class MongoSnapshotStore<T, TKey> : MongoRepositoryBase<MongoState<T, TKey>>, ISnapshotStore<T, TKey>
{ {
public MongoSnapshotStore(IMongoDatabase database) public MongoSnapshotStore(IMongoDatabase database, JsonSerializer jsonSerializer)
: base(database) : base(database)
{ {
Guard.NotNull(jsonSerializer, nameof(jsonSerializer));
BsonJsonConvention.Register(jsonSerializer);
} }
protected override string CollectionName() protected override string CollectionName()
@ -55,7 +60,7 @@ namespace Squidex.Infrastructure.States
} }
} }
public async Task ReadAllAsync(System.Func<T, long, Task> callback) public async Task ReadAllAsync(Func<T, long, Task> callback)
{ {
using (Profiler.TraceMethod<MongoSnapshotStore<T, TKey>>()) using (Profiler.TraceMethod<MongoSnapshotStore<T, TKey>>())
{ {

17
src/Squidex.Infrastructure/AutoAssembyTypeProvider.cs

@ -0,0 +1,17 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
namespace Squidex.Infrastructure
{
public sealed class AutoAssembyTypeProvider<T> : ITypeProvider
{
public void Map(TypeNameRegistry typeNameRegistry)
{
typeNameRegistry.MapUnmapped(typeof(T).Assembly);
}
}
}

4
src/Squidex.Infrastructure/Configuration/ConfigurationExtensions.cs

@ -7,9 +7,9 @@
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using Microsoft.Extensions.Configuration; using Squidex.Infrastructure;
namespace Squidex.Infrastructure.Configuration namespace Microsoft.Extensions.Configuration
{ {
public static class ConfigurationExtensions public static class ConfigurationExtensions
{ {

2
src/Squidex.Infrastructure/Configuration/Options.cs

@ -8,7 +8,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Squidex.Infrastructure.Configuration namespace Microsoft.Extensions.Configuration
{ {
public sealed class Options : Dictionary<string, Action> public sealed class Options : Dictionary<string, Action>
{ {

4
src/Squidex.Infrastructure/DependencyInjection/DependencyInjectionExtensions.cs

@ -7,10 +7,10 @@
using System; using System;
using System.Linq; using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using Squidex.Infrastructure;
namespace Squidex.Infrastructure.DependencyInjection namespace Microsoft.Extensions.DependencyInjection
{ {
public static class DependencyInjectionExtensions public static class DependencyInjectionExtensions
{ {

14
src/Squidex.Infrastructure/ITypeProvider.cs

@ -0,0 +1,14 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
namespace Squidex.Infrastructure
{
public interface ITypeProvider
{
void Map(TypeNameRegistry typeNameRegistry);
}
}

2
src/Squidex.Infrastructure/Log/ApplicationInfoLogAppender.cs

@ -17,7 +17,7 @@ namespace Squidex.Infrastructure.Log
private readonly string applicationSessionId; private readonly string applicationSessionId;
public ApplicationInfoLogAppender(Type type, Guid applicationSession) public ApplicationInfoLogAppender(Type type, Guid applicationSession)
: this(type?.GetTypeInfo().Assembly, applicationSession) : this(type?.Assembly, applicationSession)
{ {
} }

2
src/Squidex.Infrastructure/Reflection/ReflectionExtensions.cs

@ -21,7 +21,7 @@ namespace Squidex.Infrastructure.Reflection
BindingFlags.Public | BindingFlags.Public |
BindingFlags.Instance; BindingFlags.Instance;
if (!type.GetTypeInfo().IsInterface) if (!type.IsInterface)
{ {
return type.GetProperties(bindingFlags); return type.GetProperties(bindingFlags);
} }

2
src/Squidex.Infrastructure/SquidexInfrastructure.cs

@ -9,7 +9,7 @@ using System.Reflection;
namespace Squidex.Infrastructure namespace Squidex.Infrastructure
{ {
public static class SquidexInfrastructure public sealed class SquidexInfrastructure
{ {
public static readonly Assembly Assembly = typeof(SquidexInfrastructure).Assembly; public static readonly Assembly Assembly = typeof(SquidexInfrastructure).Assembly;
} }

22
src/Squidex.Infrastructure/TypeNameRegistry.cs

@ -16,6 +16,17 @@ namespace Squidex.Infrastructure
private readonly Dictionary<Type, string> namesByType = new Dictionary<Type, string>(); private readonly Dictionary<Type, string> namesByType = new Dictionary<Type, string>();
private readonly Dictionary<string, Type> typesByName = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, Type> typesByName = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
public TypeNameRegistry(IEnumerable<ITypeProvider> providers = null)
{
if (providers != null)
{
foreach (var provider in providers)
{
Map(provider);
}
}
}
public TypeNameRegistry MapObsolete(Type type, string name) public TypeNameRegistry MapObsolete(Type type, string name)
{ {
Guard.NotNull(type, nameof(type)); Guard.NotNull(type, nameof(type));
@ -36,11 +47,20 @@ namespace Squidex.Infrastructure
return this; return this;
} }
public TypeNameRegistry Map(ITypeProvider provider)
{
Guard.NotNull(provider, nameof(provider));
provider.Map(this);
return this;
}
public TypeNameRegistry Map(Type type) public TypeNameRegistry Map(Type type)
{ {
Guard.NotNull(type, nameof(type)); Guard.NotNull(type, nameof(type));
var typeNameAttribute = type.GetTypeInfo().GetCustomAttribute<TypeNameAttribute>(); var typeNameAttribute = type.GetCustomAttribute<TypeNameAttribute>();
if (!string.IsNullOrWhiteSpace(typeNameAttribute?.TypeName)) if (!string.IsNullOrWhiteSpace(typeNameAttribute?.TypeName))
{ {

1
src/Squidex/Areas/Api/Config/Swagger/SwaggerServices.cs

@ -15,7 +15,6 @@ using NSwag.SwaggerGeneration.Processors;
using Squidex.Areas.Api.Controllers.Contents.Generator; using Squidex.Areas.Api.Controllers.Contents.Generator;
using Squidex.Areas.Api.Controllers.Rules.Models; using Squidex.Areas.Api.Controllers.Rules.Models;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.DependencyInjection;
namespace Squidex.Areas.Api.Config.Swagger namespace Squidex.Areas.Api.Config.Swagger
{ {

2
src/Squidex/Areas/Api/Config/Swagger/XmlTagProcessor.cs

@ -22,7 +22,7 @@ namespace Squidex.Areas.Api.Config.Swagger
{ {
foreach (var controllerType in context.ControllerTypes) foreach (var controllerType in context.ControllerTypes)
{ {
var attribute = controllerType.GetTypeInfo().GetCustomAttribute<ApiExplorerSettingsAttribute>(); var attribute = controllerType.GetCustomAttribute<ApiExplorerSettingsAttribute>();
if (attribute != null) if (attribute != null)
{ {

4
src/Squidex/Areas/Api/Controllers/Rules/Models/RuleActionConverter.cs

@ -7,15 +7,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Domain.Apps.Core.Rules; using Squidex.Domain.Apps.Core.Rules;
namespace Squidex.Areas.Api.Controllers.Rules.Models namespace Squidex.Areas.Api.Controllers.Rules.Models
{ {
public sealed class RuleActionConverter : MyJsonInheritanceConverter<RuleAction> public sealed class RuleActionConverter : MyJsonInheritanceConverter<RuleAction>
{ {
private static readonly Dictionary<string, Type> Mapping = RuleActionRegistry.Actions.ToDictionary(x => x.Key, x => x.Value.Type); public static IReadOnlyDictionary<string, Type> Mapping { get; set; }
public RuleActionConverter() public RuleActionConverter()
: base("actionType", Mapping) : base("actionType", Mapping)

16
src/Squidex/Areas/Api/Controllers/Rules/Models/RuleActionProcessor.cs

@ -13,11 +13,21 @@ using NSwag.SwaggerGeneration.Processors;
using NSwag.SwaggerGeneration.Processors.Contexts; using NSwag.SwaggerGeneration.Processors.Contexts;
using Squidex.Domain.Apps.Core.HandleRules; using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Domain.Apps.Core.Rules; using Squidex.Domain.Apps.Core.Rules;
using Squidex.Infrastructure;
namespace Squidex.Areas.Api.Controllers.Rules.Models namespace Squidex.Areas.Api.Controllers.Rules.Models
{ {
public sealed class RuleActionProcessor : IDocumentProcessor public sealed class RuleActionProcessor : IDocumentProcessor
{ {
private readonly RuleRegistry ruleRegistry;
public RuleActionProcessor(RuleRegistry ruleRegistry)
{
Guard.NotNull(ruleRegistry, nameof(ruleRegistry));
this.ruleRegistry = ruleRegistry;
}
public async Task ProcessAsync(DocumentProcessorContext context) public async Task ProcessAsync(DocumentProcessorContext context)
{ {
try try
@ -36,16 +46,16 @@ namespace Squidex.Areas.Api.Controllers.Rules.Models
Type = JsonObjectType.String, IsRequired = true Type = JsonObjectType.String, IsRequired = true
}; };
foreach (var derived in RuleActionRegistry.Actions) foreach (var action in ruleRegistry.Actions)
{ {
var derivedSchema = await context.SchemaGenerator.GenerateAsync(derived.Value.Type, context.SchemaResolver); var derivedSchema = await context.SchemaGenerator.GenerateAsync(action.Value.Type, context.SchemaResolver);
var oldName = context.Document.Definitions.FirstOrDefault(x => x.Value == derivedSchema).Key; var oldName = context.Document.Definitions.FirstOrDefault(x => x.Value == derivedSchema).Key;
if (oldName != null) if (oldName != null)
{ {
context.Document.Definitions.Remove(oldName); context.Document.Definitions.Remove(oldName);
context.Document.Definitions.Add(derived.Key, derivedSchema); context.Document.Definitions.Add(action.Key, derivedSchema);
} }
} }

11
src/Squidex/Areas/Api/Controllers/Rules/RulesController.cs

@ -30,17 +30,18 @@ namespace Squidex.Areas.Api.Controllers.Rules
[ApiExplorerSettings(GroupName = nameof(Rules))] [ApiExplorerSettings(GroupName = nameof(Rules))]
public sealed class RulesController : ApiController public sealed class RulesController : ApiController
{ {
private static readonly string RuleActionsEtag = string.Join(";", RuleActionRegistry.Actions.Select(x => x.Key)).Sha256Base64();
private readonly IAppProvider appProvider; private readonly IAppProvider appProvider;
private readonly IRuleEventRepository ruleEventsRepository; private readonly IRuleEventRepository ruleEventsRepository;
private readonly RuleRegistry ruleRegistry;
public RulesController(ICommandBus commandBus, IAppProvider appProvider, public RulesController(ICommandBus commandBus, IAppProvider appProvider,
IRuleEventRepository ruleEventsRepository) IRuleEventRepository ruleEventsRepository, RuleRegistry ruleRegistry)
: base(commandBus) : base(commandBus)
{ {
this.appProvider = appProvider; this.appProvider = appProvider;
this.ruleEventsRepository = ruleEventsRepository; this.ruleEventsRepository = ruleEventsRepository;
this.ruleRegistry = ruleRegistry;
} }
/// <summary> /// <summary>
@ -56,9 +57,11 @@ namespace Squidex.Areas.Api.Controllers.Rules
[ApiCosts(0)] [ApiCosts(0)]
public IActionResult GetActions() public IActionResult GetActions()
{ {
var response = RuleActionRegistry.Actions.ToDictionary(x => x.Key, x => RuleElementDto.FromDefinition(x.Value)); var etag = string.Join(";", ruleRegistry.Actions.Select(x => x.Key)).Sha256Base64();
Response.Headers[HeaderNames.ETag] = RuleActionsEtag; var response = ruleRegistry.Actions.ToDictionary(x => x.Key, x => RuleElementDto.FromDefinition(x.Value));
Response.Headers[HeaderNames.ETag] = etag;
return Ok(response); return Ok(response);
} }

3
src/Squidex/Areas/Api/Controllers/Users/UsersController.cs

@ -9,7 +9,6 @@ using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Squidex.Areas.Api.Controllers.Users.Models; using Squidex.Areas.Api.Controllers.Users.Models;
@ -34,7 +33,7 @@ namespace Squidex.Areas.Api.Controllers.Users
static UsersController() static UsersController()
{ {
var assembly = typeof(UsersController).GetTypeInfo().Assembly; var assembly = typeof(UsersController).Assembly;
using (var avatarStream = assembly.GetManifestResourceStream("Squidex.Areas.Api.Controllers.Users.Assets.Avatar.png")) using (var avatarStream = assembly.GetManifestResourceStream("Squidex.Areas.Api.Controllers.Users.Assets.Avatar.png"))
{ {

3
src/Squidex/Areas/IdentityServer/Config/IdentityServerServices.cs

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using IdentityModel; using IdentityModel;
using IdentityServer4.Models; using IdentityServer4.Models;
@ -29,7 +28,7 @@ namespace Squidex.Areas.IdentityServer.Config
{ {
X509Certificate2 certificate; X509Certificate2 certificate;
var assembly = typeof(IdentityServerServices).GetTypeInfo().Assembly; var assembly = typeof(IdentityServerServices).Assembly;
using (var certStream = assembly.GetManifestResourceStream("Squidex.Areas.IdentityServer.Config.Cert.IdentityCert.pfx")) using (var certStream = assembly.GetManifestResourceStream("Squidex.Areas.IdentityServer.Config.Cert.IdentityCert.pfx"))
{ {

2
src/Squidex/Config/Domain/AssetServices.cs

@ -12,8 +12,6 @@ using MongoDB.Driver.GridFS;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Assets; using Squidex.Infrastructure.Assets;
using Squidex.Infrastructure.Assets.ImageSharp; using Squidex.Infrastructure.Assets.ImageSharp;
using Squidex.Infrastructure.Configuration;
using Squidex.Infrastructure.DependencyInjection;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
namespace Squidex.Config.Domain namespace Squidex.Config.Domain

2
src/Squidex/Config/Domain/EntitiesServices.cs

@ -42,8 +42,6 @@ using Squidex.Domain.Apps.Entities.Schemas.Indexes;
using Squidex.Domain.Apps.Entities.Tags; using Squidex.Domain.Apps.Entities.Tags;
using Squidex.Infrastructure.Assets; using Squidex.Infrastructure.Assets;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Configuration;
using Squidex.Infrastructure.DependencyInjection;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Migrations; using Squidex.Infrastructure.Migrations;
using Squidex.Pipeline; using Squidex.Pipeline;

1
src/Squidex/Config/Domain/EventPublishersServices.cs

@ -10,7 +10,6 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS.Events; using Squidex.Infrastructure.CQRS.Events;
using Squidex.Infrastructure.DependencyInjection;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Json; using Squidex.Infrastructure.Json;

12
src/Squidex/Config/Domain/EventStoreServices.cs

@ -11,8 +11,6 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Configuration;
using Squidex.Infrastructure.DependencyInjection;
using Squidex.Infrastructure.Diagnostics; using Squidex.Infrastructure.Diagnostics;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.EventSourcing.Grains; using Squidex.Infrastructure.EventSourcing.Grains;
@ -47,12 +45,14 @@ namespace Squidex.Config.Domain
var eventStoreProjectionHost = config.GetRequiredValue("eventStore:getEventStore:projectionHost"); var eventStoreProjectionHost = config.GetRequiredValue("eventStore:getEventStore:projectionHost");
var eventStorePrefix = config.GetValue<string>("eventStore:getEventStore:prefix"); var eventStorePrefix = config.GetValue<string>("eventStore:getEventStore:prefix");
var connection = EventStoreConnection.Create(eventStoreConfiguration); services.AddSingletonAs(_ => EventStoreConnection.Create(eventStoreConfiguration))
services.AddSingletonAs(connection)
.As<IEventStoreConnection>(); .As<IEventStoreConnection>();
services.AddSingletonAs(c => new GetEventStore(connection, c.GetRequiredService<IJsonSerializer>(), eventStorePrefix, eventStoreProjectionHost)) services.AddSingletonAs(c => new GetEventStore(
c.GetRequiredService<IEventStoreConnection>(),
c.GetRequiredService<IJsonSerializer>(),
eventStorePrefix,
eventStoreProjectionHost))
.AsOptional<IEventStore>(); .AsOptional<IEventStore>();
services.AddHealthChecks() services.AddHealthChecks()

1
src/Squidex/Config/Domain/InfrastructureServices.cs

@ -18,7 +18,6 @@ using Squidex.Domain.Apps.Entities.Apps.Diagnostics;
using Squidex.Domain.Users; using Squidex.Domain.Users;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Caching; using Squidex.Infrastructure.Caching;
using Squidex.Infrastructure.DependencyInjection;
using Squidex.Infrastructure.Diagnostics; using Squidex.Infrastructure.Diagnostics;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;
using Squidex.Infrastructure.UsageTracking; using Squidex.Infrastructure.UsageTracking;

1
src/Squidex/Config/Domain/LoggingServices.cs

@ -9,7 +9,6 @@ using System;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Domain.Apps.Entities.Apps; using Squidex.Domain.Apps.Entities.Apps;
using Squidex.Infrastructure.DependencyInjection;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Pipeline; using Squidex.Pipeline;

10
src/Squidex/Config/Domain/RuleServices.cs

@ -12,7 +12,7 @@ using Squidex.Domain.Apps.Entities.Contents;
using Squidex.Domain.Apps.Entities.Rules; using Squidex.Domain.Apps.Entities.Rules;
using Squidex.Domain.Apps.Entities.Rules.UsageTracking; using Squidex.Domain.Apps.Entities.Rules.UsageTracking;
using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure.DependencyInjection; using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
namespace Squidex.Config.Domain namespace Squidex.Config.Domain
@ -39,16 +39,14 @@ namespace Squidex.Config.Domain
services.AddSingletonAs<RuleEnqueuer>() services.AddSingletonAs<RuleEnqueuer>()
.As<IEventConsumer>(); .As<IEventConsumer>();
services.AddSingletonAs<RuleRegistry>()
.As<ITypeProvider>().AsSelf();
services.AddSingletonAs<RuleEventFormatter>() services.AddSingletonAs<RuleEventFormatter>()
.AsSelf(); .AsSelf();
services.AddSingletonAs<RuleService>() services.AddSingletonAs<RuleService>()
.AsSelf(); .AsSelf();
foreach (var actionHandler in RuleActionRegistry.ActionHandlers)
{
services.AddSingleton(typeof(IRuleActionHandler), actionHandler);
}
} }
} }
} }

41
src/Squidex/Config/Domain/SerializationInitializer.cs

@ -0,0 +1,41 @@
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Squidex.Areas.Api.Controllers.Rules.Models;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Infrastructure;
using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Config.Domain
{
public sealed class SerializationInitializer : IInitializable
{
private readonly JsonSerializer jsonSerializer;
private readonly RuleRegistry ruleRegistry;
public SerializationInitializer(JsonSerializer jsonSerializer, RuleRegistry ruleRegistry)
{
this.jsonSerializer = jsonSerializer;
this.ruleRegistry = ruleRegistry;
}
public Task InitializeAsync(CancellationToken ct = default)
{
BsonJsonConvention.Register(jsonSerializer);
RuleActionConverter.Mapping = ruleRegistry.Actions.ToDictionary(x => x.Key, x => x.Value.Type);
return TaskHelper.Done;
}
}
}

68
src/Squidex/Config/Domain/SerializationServices.cs

@ -11,7 +11,6 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
using Squidex.Domain.Apps.Core; using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Apps.Json; using Squidex.Domain.Apps.Core.Apps.Json;
using Squidex.Domain.Apps.Core.HandleRules;
using Squidex.Domain.Apps.Core.Rules.Json; using Squidex.Domain.Apps.Core.Rules.Json;
using Squidex.Domain.Apps.Core.Schemas; using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Core.Schemas.Json; using Squidex.Domain.Apps.Core.Schemas.Json;
@ -24,23 +23,8 @@ namespace Squidex.Config.Domain
{ {
public static class SerializationServices public static class SerializationServices
{ {
private static readonly TypeNameRegistry TypeNameRegistry = private static JsonSerializerSettings ConfigureJson(JsonSerializerSettings settings, TypeNameHandling typeNameHandling)
new TypeNameRegistry()
.MapFields()
.MapRules()
.MapRuleActions()
.MapUnmapped(SquidexCoreModel.Assembly)
.MapUnmapped(SquidexEvents.Assembly)
.MapUnmapped(SquidexInfrastructure.Assembly)
.MapUnmapped(SquidexMigrations.Assembly);
public static readonly JsonSerializerSettings DefaultJsonSettings = new JsonSerializerSettings();
public static readonly JsonSerializer DefaultJsonSerializer;
private static void ConfigureJson(JsonSerializerSettings settings, TypeNameHandling typeNameHandling)
{ {
settings.SerializationBinder = new TypeNameSerializationBinder(TypeNameRegistry);
settings.ContractResolver = new ConverterContractResolver( settings.ContractResolver = new ConverterContractResolver(
new AppClientsConverter(), new AppClientsConverter(),
new AppContributorsConverter(), new AppContributorsConverter(),
@ -66,22 +50,52 @@ namespace Squidex.Config.Domain
settings.DateParseHandling = DateParseHandling.None; settings.DateParseHandling = DateParseHandling.None;
settings.TypeNameHandling = typeNameHandling; settings.TypeNameHandling = typeNameHandling;
}
static SerializationServices()
{
ConfigureJson(DefaultJsonSettings, TypeNameHandling.Auto);
DefaultJsonSerializer = JsonSerializer.Create(DefaultJsonSettings); return settings;
} }
public static IServiceCollection AddMySerializers(this IServiceCollection services) public static IServiceCollection AddMySerializers(this IServiceCollection services)
{ {
services.AddSingleton(DefaultJsonSettings); services.AddSingletonAs<AutoAssembyTypeProvider<SquidexCoreModel>>()
services.AddSingleton(DefaultJsonSerializer); .As<ITypeProvider>();
services.AddSingleton(TypeNameRegistry);
services.AddSingletonAs<AutoAssembyTypeProvider<SquidexEvents>>()
.As<ITypeProvider>();
services.AddSingletonAs<AutoAssembyTypeProvider<SquidexInfrastructure>>()
.As<ITypeProvider>();
services.AddSingletonAs<AutoAssembyTypeProvider<SquidexMigrations>>()
.As<ITypeProvider>();
services.AddSingletonAs<FieldRegistry>()
.As<ITypeProvider>();
services.AddSingletonAs<NewtonsoftJsonSerializer>()
.As<IJsonSerializer>();
services.AddSingletonAs<SerializationInitializer>()
.AsSelf();
services.AddSingletonAs<TypeNameRegistry>()
.AsSelf();
services.AddSingletonAs(c => JsonSerializer.Create(c.GetRequiredService<JsonSerializerSettings>()))
.AsSelf();
services.AddSingletonAs(c =>
{
var serializerSettings = ConfigureJson(new JsonSerializerSettings(), TypeNameHandling.Auto);
var typeNameRegistry = c.GetService<TypeNameRegistry>();
if (typeNameRegistry != null)
{
serializerSettings.SerializationBinder = new TypeNameSerializationBinder(typeNameRegistry);
}
services.AddSingleton<IJsonSerializer>(new NewtonsoftJsonSerializer(DefaultJsonSettings)); return serializerSettings;
}).As<JsonSerializerSettings>();
return services; return services;
} }

27
src/Squidex/Config/Domain/StoreServices.cs

@ -27,13 +27,10 @@ using Squidex.Domain.Users;
using Squidex.Domain.Users.MongoDb; using Squidex.Domain.Users.MongoDb;
using Squidex.Domain.Users.MongoDb.Infrastructure; using Squidex.Domain.Users.MongoDb.Infrastructure;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Configuration;
using Squidex.Infrastructure.DependencyInjection;
using Squidex.Infrastructure.Diagnostics; using Squidex.Infrastructure.Diagnostics;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Json; using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.Migrations; using Squidex.Infrastructure.Migrations;
using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
using Squidex.Infrastructure.UsageTracking; using Squidex.Infrastructure.UsageTracking;
@ -47,23 +44,20 @@ namespace Squidex.Config.Domain
{ {
["MongoDB"] = () => ["MongoDB"] = () =>
{ {
BsonJsonConvention.Register(SerializationServices.DefaultJsonSerializer);
var mongoConfiguration = config.GetRequiredValue("store:mongoDb:configuration"); var mongoConfiguration = config.GetRequiredValue("store:mongoDb:configuration");
var mongoDatabaseName = config.GetRequiredValue("store:mongoDb:database"); var mongoDatabaseName = config.GetRequiredValue("store:mongoDb:database");
var mongoContentDatabaseName = config.GetOptionalValue("store:mongoDb:contentDatabase", mongoDatabaseName); var mongoContentDatabaseName = config.GetOptionalValue("store:mongoDb:contentDatabase", mongoDatabaseName);
var mongoClient = Singletons<IMongoClient>.GetOrAdd(mongoConfiguration, s => new MongoClient(s));
var mongoDatabase = mongoClient.GetDatabase(mongoDatabaseName);
var mongoContentDatabase = mongoClient.GetDatabase(mongoContentDatabaseName);
services.AddSingleton(typeof(ISnapshotStore<,>), typeof(MongoSnapshotStore<,>)); services.AddSingleton(typeof(ISnapshotStore<,>), typeof(MongoSnapshotStore<,>));
services.AddSingletonAs(mongoDatabase) services.AddSingletonAs(c => Singletons<IMongoClient>.GetOrAdd(mongoConfiguration, s => new MongoClient(s)))
.As<IMongoClient>();
services.AddSingletonAs(c => c.GetRequiredService<IMongoClient>().GetDatabase(mongoDatabaseName))
.As<IMongoDatabase>(); .As<IMongoDatabase>();
services.AddHealthChecks() services.AddTransientAs(c => new DeleteContentCollections(c.GetRequiredService<IMongoClient>().GetDatabase(mongoContentDatabaseName)))
.AddCheck<MongoDBHealthCheck>("MongoDB", tags: new[] { "node" }); .As<IMigration>();
services.AddSingletonAs<MongoMigrationStatus>() services.AddSingletonAs<MongoMigrationStatus>()
.As<IMigrationStatus>(); .As<IMigrationStatus>();
@ -74,8 +68,8 @@ namespace Squidex.Config.Domain
services.AddTransientAs<ConvertRuleEventsJson>() services.AddTransientAs<ConvertRuleEventsJson>()
.As<IMigration>(); .As<IMigration>();
services.AddTransientAs(c => new DeleteContentCollections(mongoContentDatabase)) services.AddHealthChecks()
.As<IMigration>(); .AddCheck<MongoDBHealthCheck>("MongoDB", tags: new[] { "node" });
services.AddSingletonAs<MongoUsageRepository>() services.AddSingletonAs<MongoUsageRepository>()
.AsOptional<IUsageRepository>(); .AsOptional<IUsageRepository>();
@ -100,7 +94,10 @@ namespace Squidex.Config.Domain
.AsOptional<IAssetRepository>() .AsOptional<IAssetRepository>()
.AsOptional<ISnapshotStore<AssetState, Guid>>(); .AsOptional<ISnapshotStore<AssetState, Guid>>();
services.AddSingletonAs(c => new MongoContentRepository(mongoContentDatabase, c.GetRequiredService<IAppProvider>(), c.GetRequiredService<IJsonSerializer>())) services.AddSingletonAs(c => new MongoContentRepository(
c.GetRequiredService<IMongoClient>().GetDatabase(mongoContentDatabaseName),
c.GetRequiredService<IAppProvider>(),
c.GetRequiredService<IJsonSerializer>()))
.AsOptional<IContentRepository>() .AsOptional<IContentRepository>()
.AsOptional<ISnapshotStore<ContentState, Guid>>() .AsOptional<ISnapshotStore<ContentState, Guid>>()
.AsOptional<IEventConsumer>(); .AsOptional<IEventConsumer>();

1
src/Squidex/Config/Domain/SubscriptionServices.cs

@ -12,7 +12,6 @@ using Squidex.Domain.Apps.Entities.Apps.Services;
using Squidex.Domain.Apps.Entities.Apps.Services.Implementations; using Squidex.Domain.Apps.Entities.Apps.Services.Implementations;
using Squidex.Domain.Users; using Squidex.Domain.Users;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.DependencyInjection;
namespace Squidex.Config.Domain namespace Squidex.Config.Domain
{ {

1
src/Squidex/Config/Orleans/OrleansServices.cs

@ -15,7 +15,6 @@ using Orleans.Hosting;
using Squidex.Domain.Apps.Entities.Contents; using Squidex.Domain.Apps.Entities.Contents;
using Squidex.Domain.Apps.Entities.Rules; using Squidex.Domain.Apps.Entities.Rules;
using Squidex.Domain.Apps.Entities.Rules.UsageTracking; using Squidex.Domain.Apps.Entities.Rules.UsageTracking;
using Squidex.Infrastructure.Configuration;
using Squidex.Infrastructure.EventSourcing.Grains; using Squidex.Infrastructure.EventSourcing.Grains;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;

1
src/Squidex/Config/Web/WebServices.cs

@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Squidex.Config.Domain; using Squidex.Config.Domain;
using Squidex.Infrastructure.DependencyInjection;
using Squidex.Pipeline; using Squidex.Pipeline;
using Squidex.Pipeline.Plugins; using Squidex.Pipeline.Plugins;
using Squidex.Pipeline.Robots; using Squidex.Pipeline.Robots;

3
src/Squidex/Pipeline/Squid/SquidMiddleware.cs

@ -7,7 +7,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@ -128,7 +127,7 @@ namespace Squidex.Pipeline.Squid
private static string LoadSvg(string name) private static string LoadSvg(string name)
{ {
var assembly = typeof(SquidMiddleware).GetTypeInfo().Assembly; var assembly = typeof(SquidMiddleware).Assembly;
using (var resourceStream = assembly.GetManifestResourceStream($"Squidex.Pipeline.Squid.icon-{name}.svg")) using (var resourceStream = assembly.GetManifestResourceStream($"Squidex.Pipeline.Squid.icon-{name}.svg"))
{ {

3
src/Squidex/Pipeline/Swagger/NSwagHelper.cs

@ -9,7 +9,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using NJsonSchema; using NJsonSchema;
@ -23,7 +22,7 @@ namespace Squidex.Pipeline.Swagger
{ {
public static string LoadDocs(string name) public static string LoadDocs(string name)
{ {
var assembly = typeof(NSwagHelper).GetTypeInfo().Assembly; var assembly = typeof(NSwagHelper).Assembly;
using (var resourceStream = assembly.GetManifestResourceStream($"Squidex.Docs.{name}.md")) using (var resourceStream = assembly.GetManifestResourceStream($"Squidex.Docs.{name}.md"))
{ {

1
src/Squidex/WebStartup.cs

@ -26,7 +26,6 @@ using Squidex.Config.Startup;
using Squidex.Config.Web; using Squidex.Config.Web;
using Squidex.Domain.Apps.Entities.Assets; using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Domain.Apps.Entities.Contents; using Squidex.Domain.Apps.Entities.Contents;
using Squidex.Extensions.Actions.Twitter;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Diagnostics; using Squidex.Infrastructure.Diagnostics;
using Squidex.Infrastructure.Translations; using Squidex.Infrastructure.Translations;

13
tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleElementRegistry.cs → tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/RuleElementRegistryTests.cs

@ -15,8 +15,10 @@ using Xunit;
namespace Squidex.Domain.Apps.Core.Operations.HandleRules namespace Squidex.Domain.Apps.Core.Operations.HandleRules
{ {
public class RuleElementRegistry public class RuleElementRegistryTests
{ {
private readonly RuleRegistry sut = new RuleRegistry();
private abstract class MyRuleActionHandler : RuleActionHandler<MyRuleAction, string> private abstract class MyRuleActionHandler : RuleActionHandler<MyRuleAction, string>
{ {
protected MyRuleActionHandler(RuleEventFormatter formatter) protected MyRuleActionHandler(RuleEventFormatter formatter)
@ -25,7 +27,6 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
} }
} }
[RuleActionHandler(typeof(MyRuleActionHandler))]
[RuleAction( [RuleAction(
IconImage = "<svg></svg>", IconImage = "<svg></svg>",
IconColor = "#1e5470", IconColor = "#1e5470",
@ -52,12 +53,16 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string Password { get; set; } public string Password { get; set; }
[DataType(DataType.Custom)]
public bool Boolean { get; set; } public bool Boolean { get; set; }
[DataType(DataType.Custom)]
public bool? BooleanOptional { get; set; } public bool? BooleanOptional { get; set; }
[DataType(DataType.Custom)]
public int Number { get; set; } public int Number { get; set; }
[DataType(DataType.Custom)]
public int? NumberOptional { get; set; } public int? NumberOptional { get; set; }
} }
@ -156,9 +161,9 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules
IsRequired = false IsRequired = false
}); });
RuleActionRegistry.Add<MyRuleAction>(); sut.Add<MyRuleAction>();
var currentDefinition = RuleActionRegistry.Actions.Values.First(); var currentDefinition = sut.Actions.Values.First();
currentDefinition.Should().BeEquivalentTo(expected); currentDefinition.Should().BeEquivalentTo(expected);
} }

8
tests/Squidex.Domain.Apps.Core.Tests/TestUtils.cs

@ -31,8 +31,8 @@ namespace Squidex.Domain.Apps.Core
{ {
var typeNameRegistry = var typeNameRegistry =
new TypeNameRegistry() new TypeNameRegistry()
.MapFields() .Map(new FieldRegistry())
.MapRules() .Map(new RuleRegistry())
.MapUnmapped(typeof(TestUtils).Assembly); .MapUnmapped(typeof(TestUtils).Assembly);
var serializerSettings = new JsonSerializerSettings var serializerSettings = new JsonSerializerSettings
@ -123,7 +123,7 @@ namespace Squidex.Domain.Apps.Core
foreach (var property in sut.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen")) foreach (var property in sut.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen"))
{ {
var value = var value =
property.PropertyType.GetTypeInfo().IsValueType ? property.PropertyType.IsValueType ?
Activator.CreateInstance(property.PropertyType) : Activator.CreateInstance(property.PropertyType) :
null; null;
@ -139,7 +139,7 @@ namespace Squidex.Domain.Apps.Core
foreach (var property in sut.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen")) foreach (var property in sut.GetType().GetRuntimeProperties().Where(x => x.Name != "IsFrozen"))
{ {
var value = var value =
property.PropertyType.GetTypeInfo().IsValueType ? property.PropertyType.IsValueType ?
Activator.CreateInstance(property.PropertyType) : Activator.CreateInstance(property.PropertyType) :
null; null;

41
tests/Squidex.Infrastructure.Tests/TypeNameRegistryTests.cs

@ -6,7 +6,8 @@
// ========================================================================== // ==========================================================================
using System; using System;
using System.Reflection; using System.Linq;
using FakeItEasy;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Xunit; using Xunit;
@ -26,6 +27,28 @@ namespace Squidex.Infrastructure
{ {
} }
[Fact]
public void Should_call_provider_from_constructor()
{
var provider = A.Fake<ITypeProvider>();
var registry = new TypeNameRegistry(Enumerable.Repeat(provider, 1));
A.CallTo(() => provider.Map(registry))
.MustHaveHappened();
}
[Fact]
public void Should_call_provider()
{
var provider = A.Fake<ITypeProvider>();
sut.Map(provider);
A.CallTo(() => provider.Map(sut))
.MustHaveHappened();
}
[Fact] [Fact]
public void Should_register_and_retrieve_types() public void Should_register_and_retrieve_types()
{ {
@ -50,10 +73,22 @@ namespace Squidex.Infrastructure
Assert.Equal(typeof(MyType), sut.GetType("My")); Assert.Equal(typeof(MyType), sut.GetType("My"));
} }
[Fact]
public void Should_register_with_provider_from_assembly()
{
sut.Map(new AutoAssembyTypeProvider<TypeNameRegistryTests>());
Assert.Equal("my", sut.GetName<MyType>());
Assert.Equal("my", sut.GetName(typeof(MyType)));
Assert.Equal(typeof(MyType), sut.GetType("my"));
Assert.Equal(typeof(MyType), sut.GetType("My"));
}
[Fact] [Fact]
public void Should_register_from_assembly() public void Should_register_from_assembly()
{ {
sut.MapUnmapped(typeof(TypeNameRegistryTests).GetTypeInfo().Assembly); sut.MapUnmapped(typeof(TypeNameRegistryTests).Assembly);
Assert.Equal("my", sut.GetName<MyType>()); Assert.Equal("my", sut.GetName<MyType>());
Assert.Equal("my", sut.GetName(typeof(MyType))); Assert.Equal("my", sut.GetName(typeof(MyType)));
@ -65,7 +100,7 @@ namespace Squidex.Infrastructure
[Fact] [Fact]
public void Should_register_event_type_from_assembly() public void Should_register_event_type_from_assembly()
{ {
sut.MapUnmapped(typeof(TypeNameRegistryTests).GetTypeInfo().Assembly); sut.MapUnmapped(typeof(TypeNameRegistryTests).Assembly);
Assert.Equal("MyAddedEventV2", sut.GetName<MyAdded>()); Assert.Equal("MyAddedEventV2", sut.GetName<MyAdded>());
Assert.Equal("MyAddedEventV2", sut.GetName(typeof(MyAdded))); Assert.Equal("MyAddedEventV2", sut.GetName(typeof(MyAdded)));

2
tools/Migrate_01/SquidexMigrations.cs

@ -9,7 +9,7 @@ using System.Reflection;
namespace Migrate_01 namespace Migrate_01
{ {
public static class SquidexMigrations public sealed class SquidexMigrations
{ {
public static readonly Assembly Assembly = typeof(SquidexMigrations).Assembly; public static readonly Assembly Assembly = typeof(SquidexMigrations).Assembly;
} }

Loading…
Cancel
Save