Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

107 lines
3.5 KiB

// ==========================================================================
// WriteServices.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Migrate_01;
using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Core.Scripting;
using Squidex.Domain.Apps.Entities.Apps;
using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Domain.Apps.Entities.Contents;
using Squidex.Domain.Apps.Entities.Rules;
using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Domain.Users;
using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Migrations;
using Squidex.Pipeline.CommandMiddlewares;
namespace Squidex.Config.Domain
{
public static class WriteServices
{
public static void AddMyWriteServices(this IServiceCollection services)
{
services.AddSingletonAs<NoopUserEvents>()
.As<IUserEvents>();
services.AddSingletonAs<JintScriptEngine>()
.As<IScriptEngine>();
services.AddSingletonAs<ETagCommandMiddleware>()
.As<ICommandMiddleware>();
services.AddSingletonAs<EnrichWithTimestampCommandMiddleware>()
.As<ICommandMiddleware>();
services.AddSingletonAs<EnrichWithActorCommandMiddleware>()
.As<ICommandMiddleware>();
services.AddSingletonAs<EnrichWithAppIdCommandMiddleware>()
.As<ICommandMiddleware>();
services.AddSingletonAs<EnrichWithSchemaIdCommandMiddleware>()
.As<ICommandMiddleware>();
services.AddSingletonAs<AppCommandMiddleware>()
.As<ICommandMiddleware>();
services.AddSingletonAs<AssetCommandMiddleware>()
.As<ICommandMiddleware>();
services.AddSingletonAs<ContentCommandMiddleware>()
.As<ICommandMiddleware>();
services.AddSingletonAs<SchemaCommandMiddleware>()
.As<ICommandMiddleware>();
services.AddSingletonAs<RuleCommandMiddleware>()
.As<ICommandMiddleware>();
services.AddTransientAs<Migration01_FromCqrs>()
.As<IMigration>();
services.AddTransientAs<Migration02_AddPatterns>()
.As<IMigration>();
services.AddTransientAs<AppDomainObject>()
.AsSelf();
services.AddTransientAs<AssetDomainObject>()
.AsSelf();
services.AddTransientAs<ContentDomainObject>()
.AsSelf();
services.AddTransientAs<RuleDomainObject>()
.AsSelf();
services.AddTransientAs<SchemaDomainObject>()
.AsSelf();
services.AddSingleton<InitialPatterns>(c =>
{
var config = c.GetRequiredService<IOptions<MyUIOptions>>();
var result = new InitialPatterns();
foreach (var pattern in config.Value.RegexSuggestions)
{
if (!string.IsNullOrWhiteSpace(pattern.Key) &&
!string.IsNullOrWhiteSpace(pattern.Value))
{
result[Guid.NewGuid()] = new AppPattern(pattern.Key, pattern.Value);
}
}
return result;
});
}
}
}