mirror of https://github.com/Squidex/squidex.git
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.
88 lines
2.8 KiB
88 lines
2.8 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using Microsoft.Extensions.Options;
|
|
using Squidex.AI;
|
|
using Squidex.Areas.Api.Controllers.UI;
|
|
using Squidex.Domain.Apps.Core.Apps;
|
|
using Squidex.Domain.Apps.Entities;
|
|
using Squidex.Domain.Apps.Entities.Apps;
|
|
using Squidex.Domain.Apps.Entities.History;
|
|
using Squidex.Domain.Apps.Entities.Search;
|
|
using Squidex.Infrastructure.Collections;
|
|
using Squidex.Infrastructure.EventSourcing;
|
|
|
|
namespace Squidex.Config.Domain;
|
|
|
|
public static class AppsServices
|
|
{
|
|
public static void AddSquidexApps(this IServiceCollection services, IConfiguration config)
|
|
{
|
|
if (config.GetValue<bool>("apps:deletePermanent"))
|
|
{
|
|
services.AddSingletonAs<AppPermanentDeleter>()
|
|
.As<IEventConsumer>();
|
|
}
|
|
|
|
services.AddSingletonAs<RolePermissionsProvider>()
|
|
.AsSelf();
|
|
|
|
services.AddSingletonAs<AppEventDeleter>()
|
|
.As<IDeleter>();
|
|
|
|
services.AddSingletonAs<AppUsageDeleter>()
|
|
.As<IDeleter>();
|
|
|
|
services.AddSingletonAs<DefaultAppLogStore>()
|
|
.As<IAppLogStore>().As<IDeleter>();
|
|
|
|
services.AddSingletonAs<AppHistoryEventsCreator>()
|
|
.As<IHistoryEventsCreator>();
|
|
|
|
services.AddSingletonAs<DefaultAppImageStore>()
|
|
.As<IAppImageStore>();
|
|
|
|
services.AddSingletonAs<AppProvider>()
|
|
.As<IAppProvider>();
|
|
|
|
services.AddSingletonAs<AppUISettings>()
|
|
.As<IAppUISettings>().As<IDeleter>();
|
|
|
|
services.AddSingletonAs<AppChatTools>()
|
|
.As<IChatToolProvider>();
|
|
|
|
services.AddSingletonAs<AppSettingsSearchSource>()
|
|
.As<ISearchSource>();
|
|
|
|
services.AddSingleton(c =>
|
|
{
|
|
var uiOptions = c.GetRequiredService<IOptions<MyUIOptions>>().Value;
|
|
|
|
var patterns = new List<Pattern>();
|
|
|
|
if (uiOptions.RegexSuggestions != null)
|
|
{
|
|
foreach (var (key, value) in uiOptions.RegexSuggestions)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(key) &&
|
|
!string.IsNullOrWhiteSpace(value))
|
|
{
|
|
patterns.Add(new Pattern(key, value));
|
|
}
|
|
}
|
|
}
|
|
|
|
return new InitialSettings
|
|
{
|
|
Settings = new AppSettings
|
|
{
|
|
Patterns = patterns.ToReadonlyList()
|
|
}
|
|
};
|
|
});
|
|
}
|
|
}
|
|
|