Files
Umbraco-CMS/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Services.cs

89 lines
4.4 KiB
C#
Raw Normal View History

using System;
2018-07-20 09:49:05 +02:00
using System.IO;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
2020-09-21 08:19:26 +02:00
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Packaging;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Services.Implement;
using Umbraco.Cms.Infrastructure.Packaging;
using Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement;
2022-04-20 15:42:27 +02:00
using Umbraco.Cms.Infrastructure.Services.Implement;
using Umbraco.Cms.Infrastructure.Telemetry.Providers;
using Umbraco.Cms.Infrastructure.Templates;
using Umbraco.Extensions;
2018-07-20 09:49:05 +02:00
namespace Umbraco.Cms.Infrastructure.DependencyInjection
2018-07-20 09:49:05 +02:00
{
public static partial class UmbracoBuilderExtensions
2018-07-20 09:49:05 +02:00
{
/// <summary>
/// Adds Umbraco services
/// </summary>
internal static IUmbracoBuilder AddServices(this IUmbracoBuilder builder)
2018-07-20 09:49:05 +02:00
{
// register the service context
builder.Services.AddSingleton<ServiceContext>();
2018-07-20 09:49:05 +02:00
// register the special idk map
builder.Services.AddUnique<IIdKeyMap, IdKeyMap>();
2018-07-20 09:49:05 +02:00
builder.Services.AddUnique<IAuditService, AuditService>();
builder.Services.AddUnique<ICacheInstructionService, CacheInstructionService>();
2021-08-06 09:51:08 +02:00
builder.Services.AddUnique<IBasicAuthService, BasicAuthService>();
builder.Services.AddUnique<IDataTypeService, DataTypeService>();
builder.Services.AddUnique<IPackagingService, PackagingService>();
builder.Services.AddUnique<IServerRegistrationService, ServerRegistrationService>();
Member 2FA (#11889) * Bugfix - Take ufprt from form data if the request has form content type, otherwise fallback to use the query * External linking for members * Changed migration to reuse old table * removed unnecessary web.config files * Cleanup * Extracted class to own file * Clean up * Rollback changes to Umbraco.Web.UI.csproj * Fixed migration for SqlCE * Added 2fa for members * Change notification handler to be on deleted * Update src/Umbraco.Infrastructure/Security/MemberUserStore.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * updated snippets * Fixed issue with errors not shown on member linking * fixed issue with errors * clean up * Fix issue where external logins could not be used to upgrade Umbraco, because the externalLogin table was expected to look different. (Like after the migration) * Fixed issue in Ignore legacy column now using result column. * Updated 2fa for members + publish notification when 2fa is requested. * Changed so only Members out of box supports 2fa * Cleanup * rollback of csproj file, that should not have been changed * Removed confirmed flag from db. It was not used. Handle case where a user is signed up for 2fa, but the provider do not exist anymore. Then it is just ignored until it shows up again Reintroduced ProviderName on interface, to ensure the class can be renamed safely * Bugfix * Registering DeleteTwoFactorLoginsOnMemberDeletedHandler * Rollback nuget packages added by mistake * Update src/Umbraco.Infrastructure/Services/Implement/TwoFactorLoginService.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TwoFactorLoginRepository.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Added providername to snippet Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
2022-01-21 13:10:34 +01:00
builder.Services.AddUnique<ITwoFactorLoginService, TwoFactorLoginService>();
builder.Services.AddTransient(SourcesFactory);
builder.Services.AddUnique(factory => CreatePackageRepository(factory, "createdPackages.config"));
builder.Services.AddUnique<ICreatedPackagesRepository, CreatedPackageSchemaRepository>();
builder.Services.AddSingleton<PackageDataInstallation>();
builder.Services.AddUnique<IPackageInstallation, PackageInstallation>();
builder.Services.AddUnique<IHtmlMacroParameterParser, HtmlMacroParameterParser>();
v9: Implement telemetry levels (#12267) * Add initial classes * Add TelemetryProviders * Add new NodeCountService.cs and NodeTelemetryProvider * Add data contract attribute to UsageInformation Otherwise it wont serialize correctly * Implement more providers * Fix builders and propertyEditorTelemetry * Add MediaTelemetryProvider * Add MediaTelemetryProvider * Fix doubling of media telemetry * Move contentCount from NodeCountTelemetryProvider and move to ContentTelemetryProvider * Revert ContentTelemetryProvider changes * Add detailed information to TelemetryService * Add integration tests * Add more tests and todos for tests * Fix stylecop warnings * Use yield return instead of instantiating local list * Implement Macro test * Inject interface instead of implementation in TelemetryService * Fix TelemetryServiceTests.cs * Implement media tests * Implement propertyTypeTests * Implement constants instead of hardcoded strings * Add SystemInformationTelemetryProvider * Use SystemInformationTableDataProvider in UserDataService * Implement more properties * Add UsageInformation * Replace UserDataService with SystemInformationTelemetryProvider * Undo changes to UserDataService and obsolete it * Remove ISystemInformationTableDataProvider * Register SystemInformationTelemetryProvider as telemetry provider * Use constants for telemetry names * Make UserDataServiceTests test SystemInformationTelemetryProvider instead * Update UserDataServiceTests to cover new data * Add unit tests * Add integration test testing expected data is returned * Implement Analytics dashboard * Improve assertion message * Add text and styling to analyticspage * Rename consent to analytic * implement save button for consent level * Implement save button * Fix system information test * Add TelemetryResource * Move telemetry providers to infrastructure * Add database provider to system information * Set startvalue for slider * Fix unit tests * Implement MetricsConsentService using KeyValueService * Return void hen setting the telemetry level * fix startposition when not reloading * Add a couple tests * Update src/Umbraco.Core/Services/MetricsConsentService.cs * Rename ConsentLevel.cs * Use direct Enum instead of parsing * rename consent resource * add lazy database * refactor slider * Implement ng-if and propers pips * Make classes internal * Fix slider not loading when navigating to tab * Add telemetry level check to TelemetryService.cs * Add Consent for analytics text * Fix build errors for unit tests * Fix TelemetryServiceTests * revert package-lock.json * Fix integration test * Update slider * Update TelemetryService.cs * Apply suggestions from code review Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> Co-authored-by: Nikolaj Geisle <niko737@edu.ucl.dk> Co-authored-by: nikolajlauridsen <nikolajlauridsen@protonmail.ch>
2022-04-19 15:06:10 +02:00
builder.Services.AddTransient<IExamineIndexCountService, ExamineIndexCountService>();
builder.Services.AddUnique<IUserDataService, SystemInformationTelemetryProvider>();
builder.Services.AddTransient<IUsageInformationService, UsageInformationService>();
return builder;
2018-07-20 15:45:01 +02:00
}
private static PackagesRepository CreatePackageRepository(IServiceProvider factory, string packageRepoFileName)
2019-01-18 10:02:47 +01:00
=> new PackagesRepository(
factory.GetRequiredService<IContentService>(),
factory.GetRequiredService<IContentTypeService>(),
factory.GetRequiredService<IDataTypeService>(),
factory.GetRequiredService<IFileService>(),
factory.GetRequiredService<IMacroService>(),
factory.GetRequiredService<ILocalizationService>(),
factory.GetRequiredService<IHostingEnvironment>(),
factory.GetRequiredService<IEntityXmlSerializer>(),
factory.GetRequiredService<IOptions<GlobalSettings>>(),
factory.GetRequiredService<IMediaService>(),
factory.GetRequiredService<IMediaTypeService>(),
factory.GetRequiredService<MediaFileManager>(),
factory.GetRequiredService<FileSystems>(),
packageRepoFileName);
private static LocalizedTextServiceFileSources SourcesFactory(IServiceProvider container)
2018-07-20 15:45:01 +02:00
{
var hostingEnvironment = container.GetRequiredService<IHostingEnvironment>();
var mainLangFolder = new DirectoryInfo(hostingEnvironment.MapPathContentRoot(WebPath.Combine(Constants.SystemDirectories.Umbraco, "config", "lang")));
2018-07-20 09:49:05 +02:00
2018-07-20 15:45:01 +02:00
return new LocalizedTextServiceFileSources(
container.GetRequiredService<ILogger<LocalizedTextServiceFileSources>>(),
container.GetRequiredService<AppCaches>(),
2018-07-20 15:45:01 +02:00
mainLangFolder,
container.GetServices<LocalizedTextServiceSupplementaryFileSource>());
2018-07-20 09:49:05 +02:00
}
}
}