AB3677 - Removed the Core.Composing.Current.. Moved stuff to Web.Composing.Current and injected more stuff.

This commit is contained in:
Bjarke Berg
2020-01-07 13:08:21 +01:00
parent 58f9b48e16
commit d2443ea4c0
113 changed files with 451 additions and 386 deletions
-60
View File
@@ -1,60 +0,0 @@
using System;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
namespace Umbraco.Core.Composing
{
/// <summary>
/// Provides a static service locator for most singletons.
/// </summary>
/// <remarks>
/// <para>This class is initialized with the container in UmbracoApplicationBase,
/// right after the container is created in UmbracoApplicationBase.HandleApplicationStart.</para>
/// <para>Obviously, this is a service locator, which some may consider an anti-pattern. And yet,
/// practically, it works.</para>
/// </remarks>
public static class Current
{
private static IFactory _factory;
/// <summary>
/// Gets or sets the factory.
/// </summary>
public static IFactory Factory
{
get
{
if (_factory == null) throw new InvalidOperationException("No factory has been set.");
return _factory;
}
set
{
if (_factory != null) throw new InvalidOperationException("A factory has already been set.");
_factory = value;
}
}
public static bool HasFactory => _factory != null;
/// <summary>
/// Resets <see cref="Current"/>. Indented for testing only, and not supported in production code.
/// </summary>
/// <remarks>
/// <para>For UNIT TESTS exclusively.</para>
/// <para>Resets everything that is 'current'.</para>
/// </remarks>
public static void Reset()
{
_factory.DisposeIfDisposable();
_factory = null;
Resetted?.Invoke(null, EventArgs.Empty);
}
internal static event EventHandler Resetted;
public static IIOHelper IOHelper
=> Factory.GetInstance<IIOHelper>();
}
}
+2 -2
View File
@@ -202,7 +202,7 @@ namespace Umbraco.Core.Runtime
composers.Compose();
// create the factory
_factory = Current.Factory = composition.CreateFactory();
_factory = composition.CreateFactory();
// create & initialize the components
_components = _factory.GetInstance<ComponentCollection>();
@@ -229,7 +229,7 @@ namespace Umbraco.Core.Runtime
{
try
{
_factory = Current.Factory = composition?.CreateFactory();
_factory = composition?.CreateFactory();
}
catch { /* yea */ }
}
-2
View File
@@ -129,7 +129,6 @@
<Compile Include="Compose\AuditEventsComponent.cs" />
<Compile Include="Compose\AuditEventsComposer.cs" />
<Compile Include="Composing\CompositionExtensions\CoreMappingProfiles.cs" />
<Compile Include="Composing\Current.cs" />
<Compile Include="Models\Identity\BackOfficeIdentityUser.cs" />
<Compile Include="Models\Identity\IdentityMapDefinition.cs" />
<Compile Include="Models\Identity\IdentityUser.cs" />
@@ -152,7 +151,6 @@
<Compile Include="Security\IUserSessionStore.cs" />
<Compile Include="Security\UmbracoEmailMessage.cs" />
<Compile Include="Security\UserAwarePasswordHasher.cs" />
<Compile Include="ServiceContextExtensions.cs" />
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
@@ -22,9 +22,6 @@ namespace Umbraco.Core.PropertyEditors
[DataContract]
public class DataEditor : IDataEditor
{
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly ILocalizedTextService _localizedTextService;
private IDictionary<string, object> _defaultConfiguration;
private IDataValueEditor _dataValueEditor;
@@ -33,11 +30,12 @@ namespace Umbraco.Core.PropertyEditors
/// </summary>
public DataEditor(ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, EditorType type = EditorType.PropertyValue)
{
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_localizedTextService = localizedTextService;
ShortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper));
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
DataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService));
LocalizationService = localizationService ?? throw new ArgumentNullException(nameof(localizationService));
LocalizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService));
ShortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper));
// defaults
Type = type;
@@ -62,6 +60,9 @@ namespace Umbraco.Core.PropertyEditors
protected DataEditorAttribute Attribute { get; }
protected IShortStringHelper ShortStringHelper { get; }
protected ILocalizedTextService LocalizedTextService { get; }
protected ILocalizationService LocalizationService { get; }
protected IDataTypeService DataTypeService { get; }
/// <summary>
/// Gets a logger.
@@ -179,7 +180,7 @@ namespace Umbraco.Core.PropertyEditors
if (Attribute == null)
throw new InvalidOperationException($"The editor is not attributed with {nameof(DataEditorAttribute)}");
return new DataValueEditor(_dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Attribute);
return new DataValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute);
}
/// <summary>
@@ -18,10 +18,7 @@ namespace Umbraco.Core.PropertyEditors
public class LabelPropertyEditor : DataEditor
{
private readonly IIOHelper _ioHelper;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizedTextService _localizedTextService;
private readonly ILocalizationService _localizationService;
private readonly IShortStringHelper _shortStringHelper;
/// <summary>
/// Initializes a new instance of the <see cref="LabelPropertyEditor"/> class.
@@ -30,14 +27,10 @@ namespace Umbraco.Core.PropertyEditors
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_ioHelper = ioHelper;
_dataTypeService = dataTypeService;
_localizedTextService = localizedTextService;
_localizationService = localizationService;
_shortStringHelper = shortStringHelper;
}
/// <inheritdoc />
protected override IDataValueEditor CreateValueEditor() => new LabelPropertyValueEditor(_dataTypeService, _localizationService,_localizedTextService, _shortStringHelper, Attribute);
protected override IDataValueEditor CreateValueEditor() => new LabelPropertyValueEditor(DataTypeService, LocalizationService,LocalizedTextService, ShortStringHelper, Attribute);
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new LabelConfigurationEditor(_ioHelper);
@@ -78,7 +78,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
value = ConfigurationManager.AppSettings[prefix + "ModelsDirectory"];
if (!string.IsNullOrWhiteSpace(value))
{
var root = Current.IOHelper.MapPath("~/");
var root = _ioHelper.MapPath("~/");
if (root == null)
throw new ConfigurationErrorsException("Could not determine root directory.");
@@ -1,7 +1,7 @@
using System;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Web.Composing;
using Umbraco.ModelsBuilder.Embedded;
// will install only if configuration says it needs to be installed
@@ -1,15 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Web.Composing;
using Umbraco.Core.Sync;
using Umbraco.Tests.Components;
using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Cache.DistributedCache
{
@@ -5,10 +5,9 @@ using Moq;
using NUnit.Framework;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Tests.TestHelpers;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Composing
{
@@ -6,10 +6,10 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Tests.Components;
using Umbraco.Tests.TestHelpers;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Composing
{
+2 -1
View File
@@ -5,8 +5,8 @@ using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.IO.MediaPathSchemes;
using Umbraco.Core.Logging;
@@ -14,6 +14,7 @@ using Umbraco.Core.Services;
using Umbraco.Tests.Components;
using Umbraco.Tests.TestHelpers;
using Umbraco.Core.Composing.CompositionExtensions;
using Current = Umbraco.Web.Composing.Current;
using FileSystems = Umbraco.Core.IO.FileSystems;
namespace Umbraco.Tests.IO
+1 -1
View File
@@ -36,7 +36,7 @@ namespace Umbraco.Tests.Models
var localizationService = Mock.Of<ILocalizationService>();
var mediaFileSystem = new MediaFileSystem(Mock.Of<IFileSystem>(), scheme, logger, ShortStringHelper);
var ignored = new FileUploadPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, config, dataTypeService, localizationService, ShortStringHelper);
var ignored = new FileUploadPropertyEditor(Mock.Of<ILogger>(), mediaFileSystem, config, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper);
var media = MockedMedia.CreateMediaImage(mediaType, -1);
media.WriterId = -1; // else it's zero and that's not a user and it breaks the tests
+6 -7
View File
@@ -1,23 +1,23 @@
using System;
using Moq;
using NUnit.Framework;
using NUnit.Framework.Internal;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
using ILogger = Umbraco.Core.Logging.ILogger;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Models
{
[TestFixture]
public class VariationTests
{
private IFactory _factory;
private IShortStringHelper ShortStringHelper { get; } = TestHelper.ShortStringHelper;
[SetUp]
@@ -37,8 +37,7 @@ namespace Umbraco.Tests.Models
configs.Add(SettingsForTests.GetDefaultGlobalSettings);
configs.Add(SettingsForTests.GetDefaultUmbracoSettings);
var factory = Mock.Of<IFactory>();
Current.Factory = factory;
_factory = Mock.Of<IFactory>();
var dataTypeService = Mock.Of<IDataTypeService>();
var localizationService = Mock.Of<ILocalizationService>();
@@ -62,7 +61,7 @@ namespace Umbraco.Tests.Models
dataTypeService: dataTypeService,
localizedTextService: Mock.Of<ILocalizedTextService>());
Mock.Get(factory)
Mock.Get(_factory)
.Setup(x => x.GetInstance(It.IsAny<Type>()))
.Returns<Type>(x =>
{
@@ -449,7 +448,7 @@ namespace Umbraco.Tests.Models
[Test]
public void ContentPublishValuesWithMixedPropertyTypeVariations()
{
var propertyValidationService = new PropertyValidationService(Current.Factory.GetInstance<PropertyEditorCollection>(), Current.Factory.GetInstance<ServiceContext>().DataTypeService);
var propertyValidationService = new PropertyValidationService(_factory.GetInstance<PropertyEditorCollection>(), _factory.GetInstance<ServiceContext>().DataTypeService);
const string langFr = "fr-FR";
// content type varies by Culture
@@ -581,7 +580,7 @@ namespace Umbraco.Tests.Models
prop.SetValue("a");
Assert.AreEqual("a", prop.GetValue());
Assert.IsNull(prop.GetValue(published: true));
var propertyValidationService = new PropertyValidationService(Current.Factory.GetInstance<PropertyEditorCollection>(), Current.Factory.GetInstance<ServiceContext>().DataTypeService);
var propertyValidationService = new PropertyValidationService(_factory.GetInstance<PropertyEditorCollection>(), _factory.GetInstance<ServiceContext>().DataTypeService);
Assert.IsTrue(propertyValidationService.IsPropertyValid(prop));
@@ -150,8 +150,8 @@ namespace Umbraco.Tests.Packaging
{
var file1 = $"~/{_testBaseFolder}/App_Plugins/MyPlugin/package.manifest";
var file2 = $"~/{_testBaseFolder}/App_Plugins/MyPlugin/styles.css";
var mappedFile1 = Current.IOHelper.MapPath(file1);
var mappedFile2 = Current.IOHelper.MapPath(file2);
var mappedFile1 = IOHelper.MapPath(file1);
var mappedFile2 = IOHelper.MapPath(file2);
Directory.CreateDirectory(Path.GetDirectoryName(mappedFile1));
Directory.CreateDirectory(Path.GetDirectoryName(mappedFile2));
File.WriteAllText(mappedFile1, "hello world");
@@ -175,7 +175,7 @@ namespace Umbraco.Tests.Packaging
def = PackageBuilder.GetById(def.Id); //re-get
Assert.IsNotNull(def.PackagePath);
using (var archive = ZipFile.OpenRead(Current.IOHelper.MapPath(zip)))
using (var archive = ZipFile.OpenRead(IOHelper.MapPath(zip)))
{
Assert.AreEqual(3, archive.Entries.Count);
@@ -36,9 +36,9 @@ namespace Umbraco.Tests.Persistence.Repositories
using (provider.CreateScope())
{
var dtRepo = CreateRepository();
IDataType dataType1 = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper, ShortStringHelper)) { Name = "dt1" };
IDataType dataType1 = new DataType(new RadioButtonsPropertyEditor(Logger, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper)) { Name = "dt1" };
dtRepo.Save(dataType1);
IDataType dataType2 = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper, ShortStringHelper)) { Name = "dt2" };
IDataType dataType2 = new DataType(new RadioButtonsPropertyEditor(Logger, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper)) { Name = "dt2" };
dtRepo.Save(dataType2);
var ctRepo = Factory.GetInstance<IContentTypeRepository>();
@@ -106,14 +106,14 @@ namespace Umbraco.Tests.Persistence.Repositories
var container2 = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah2", ParentId = container1.Id };
containerRepository.Save(container2);
var dataType = (IDataType) new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper, ShortStringHelper), container2.Id)
var dataType = (IDataType) new DataType(new RadioButtonsPropertyEditor(Logger, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), container2.Id)
{
Name = "dt1"
};
repository.Save(dataType);
//create a
var dataType2 = (IDataType)new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper, ShortStringHelper), dataType.Id)
var dataType2 = (IDataType)new DataType(new RadioButtonsPropertyEditor(Logger, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), dataType.Id)
{
Name = "dt2"
};
@@ -185,7 +185,7 @@ namespace Umbraco.Tests.Persistence.Repositories
var container = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah" };
containerRepository.Save(container);
var dataTypeDefinition = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper, ShortStringHelper), container.Id) { Name = "test" };
var dataTypeDefinition = new DataType(new RadioButtonsPropertyEditor(Logger, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), container.Id) { Name = "test" };
repository.Save(dataTypeDefinition);
Assert.AreEqual(container.Id, dataTypeDefinition.ParentId);
@@ -205,7 +205,7 @@ namespace Umbraco.Tests.Persistence.Repositories
var container = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah" };
containerRepository.Save(container);
IDataType dataType = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper, ShortStringHelper), container.Id) { Name = "test" };
IDataType dataType = new DataType(new RadioButtonsPropertyEditor(Logger, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), container.Id) { Name = "test" };
repository.Save(dataType);
// Act
@@ -228,7 +228,7 @@ namespace Umbraco.Tests.Persistence.Repositories
using (provider.CreateScope())
{
var repository = CreateRepository();
IDataType dataType = new DataType(new RadioButtonsPropertyEditor(Logger, ServiceContext.TextService, IOHelper, ShortStringHelper)) {Name = "test"};
IDataType dataType = new DataType(new RadioButtonsPropertyEditor(Logger, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper)) {Name = "test"};
repository.Save(dataType);
@@ -359,7 +359,7 @@ namespace Umbraco.Tests.Persistence.Repositories
{
var repository = CreateRepository((IScopeAccessor)provider, out var contentTypeRepository, out DataTypeRepository dataTypeDefinitionRepository);
var editor = new DecimalPropertyEditor(Logger, ShortStringHelper);
var editor = new DecimalPropertyEditor(Logger, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper);
var dtd = new DataType(editor) { Name = "test", DatabaseType = ValueStorageType.Decimal };
dataTypeDefinitionRepository.Save(dtd);
@@ -7,7 +7,6 @@ using Newtonsoft.Json.Linq;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
@@ -22,6 +21,7 @@ using Umbraco.Tests.TestHelpers;
using Umbraco.Web.Models;
using Umbraco.Web;
using Umbraco.Web.PropertyEditors;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.PropertyEditors
{
@@ -8,10 +8,10 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Tests.Components;
using Umbraco.Tests.TestHelpers;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.PropertyEditors
{
@@ -5,8 +5,7 @@ using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Exceptions;
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.PublishedContent;
@@ -15,7 +14,6 @@ using Umbraco.Core.Services;
using Umbraco.Tests.PublishedContent;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
using Umbraco.Web.Models;
using Umbraco.Web.PropertyEditors;
using Umbraco.Web.PropertyEditors.ValueConverters;
using Umbraco.Web.PublishedCache;
@@ -27,6 +27,7 @@ using Umbraco.Web.Cache;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.NuCache;
using Umbraco.Web.PublishedCache.NuCache.DataSource;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.PublishedContent
{
@@ -129,7 +130,7 @@ namespace Umbraco.Tests.PublishedContent
// create a published content type factory
var contentTypeFactory = new PublishedContentTypeFactory(
Mock.Of<IPublishedModelFactory>(),
PublishedModelFactory,
new PropertyValueConverterCollection(Array.Empty<IPropertyValueConverter>()),
dataTypeService);
@@ -161,7 +162,7 @@ namespace Umbraco.Tests.PublishedContent
_source,
globalSettings,
Mock.Of<IEntityXmlSerializer>(),
Mock.Of<IPublishedModelFactory>(),
PublishedModelFactory,
new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider(TestHelper.ShortStringHelper) }),
typeFinder,
hostingEnvironment,
@@ -26,6 +26,7 @@ using Umbraco.Web.Cache;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.NuCache;
using Umbraco.Web.PublishedCache.NuCache.DataSource;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.PublishedContent
{
@@ -175,7 +176,7 @@ namespace Umbraco.Tests.PublishedContent
// create a published content type factory
var contentTypeFactory = new PublishedContentTypeFactory(
Mock.Of<IPublishedModelFactory>(),
publishedModelFactory,
new PropertyValueConverterCollection(Array.Empty<IPropertyValueConverter>()),
dataTypeService);
@@ -203,7 +204,7 @@ namespace Umbraco.Tests.PublishedContent
dataSource,
globalSettings,
Mock.Of<IEntityXmlSerializer>(),
Mock.Of<IPublishedModelFactory>(),
publishedModelFactory,
new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider(TestHelper.ShortStringHelper) }),
typeFinder,
TestHelper.GetHostingEnvironment(),
@@ -37,7 +37,7 @@ namespace Umbraco.Tests.Routing
var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(new IDataEditor[]
{
new FileUploadPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, ShortStringHelper),
new FileUploadPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper),
new ImageCropperPropertyEditor(logger, mediaFileSystemMock, contentSection, dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService),
}));
_mediaUrlProvider = new DefaultMediaUrlProvider(propertyEditors);
@@ -50,7 +50,8 @@ namespace Umbraco.Tests.Routing
TestObjects.GetGlobalSettings(),
ShortStringHelper,
new SurfaceControllerTypeCollection(Enumerable.Empty<Type>()),
new UmbracoApiControllerTypeCollection(Enumerable.Empty<Type>()));
new UmbracoApiControllerTypeCollection(Enumerable.Empty<Type>()),
IOHelper);
}
public class TestRuntime : WebRuntime
@@ -4,10 +4,8 @@ using System.Data;
using System.Web.Hosting;
using Examine;
using Moq;
using NPoco.Expressions;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Compose;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
@@ -24,6 +22,7 @@ using Umbraco.Tests.TestHelpers.Stubs;
using Umbraco.Web;
using Umbraco.Web.Hosting;
using Umbraco.Web.Runtime;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Runtimes
{
@@ -35,6 +35,7 @@ using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
using Umbraco.Web.Runtime;
using File = System.IO.File;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Runtimes
{
@@ -48,7 +49,7 @@ namespace Umbraco.Tests.Runtimes
IFactory factory = null;
// clear
foreach (var file in Directory.GetFiles(Path.Combine(Current.IOHelper.MapPath("~/App_Data")), "NuCache.*"))
foreach (var file in Directory.GetFiles(Path.Combine(TestHelper.IOHelper.MapPath("~/App_Data")), "NuCache.*"))
File.Delete(file);
// settings
@@ -4,6 +4,7 @@ using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.IO;
@@ -11,10 +12,10 @@ using Umbraco.Core.Logging;
using Umbraco.Core.Scoping;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using Umbraco.Core.Composing;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Services;
using Umbraco.Tests.Components;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Scoping
{
@@ -102,7 +102,7 @@ namespace Umbraco.Tests.Scoping
new DatabaseDataSource(),
Factory.GetInstance<IGlobalSettings>(),
Factory.GetInstance<IEntityXmlSerializer>(),
Mock.Of<IPublishedModelFactory>(),
new NoopPublishedModelFactory(),
new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider(ShortStringHelper) }),
typeFinder,
hostingEnvironment,
@@ -5,14 +5,13 @@ using NPoco;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Persistence;
using Umbraco.Tests.Components;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.TestHelpers
{
@@ -7,9 +7,10 @@ using System.Web.Routing;
using System.Web.SessionState;
using Moq;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Web;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.TestHelpers.Stubs
{
+2 -3
View File
@@ -38,23 +38,22 @@ using Umbraco.Web.Actions;
using Umbraco.Web.ContentApps;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
using Umbraco.Web.Trees;
using Umbraco.Core.Composing.CompositionExtensions;
using Umbraco.Core.Hosting;
using Umbraco.Core.Mapping;
using Umbraco.Core.Serialization;
using Umbraco.Web.Composing.CompositionExtensions;
using Umbraco.Web.Composing;
using Umbraco.Web.Hosting;
using Umbraco.Web.Sections;
using Current = Umbraco.Core.Composing.Current;
using FileSystems = Umbraco.Core.IO.FileSystems;
using Umbraco.Web.Templates;
using Umbraco.Web.PropertyEditors;
using Umbraco.Core.Dictionary;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Net;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Testing
{
@@ -12,18 +12,15 @@ using Newtonsoft.Json.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Dictionary;
using Umbraco.Core.Logging;
using Umbraco.Web.Composing;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Persistence;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.ControllerTesting;
using Umbraco.Tests.TestHelpers.Entities;
@@ -35,6 +32,7 @@ using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.PropertyEditors;
using Umbraco.Web.Trees;
using Umbraco.Web.WebApi;
using Umbraco.Web.Composing;
using Task = System.Threading.Tasks.Task;
namespace Umbraco.Tests.Web.Controllers
@@ -14,7 +14,7 @@ namespace Umbraco.Tests.Web.Controllers
public void Ensure_Same_Area1()
{
Assert.Throws<InvalidOperationException>(() =>
new PluginControllerArea(TestObjects.GetGlobalSettings(),
new PluginControllerArea(TestObjects.GetGlobalSettings(), IOHelper,
new PluginControllerMetadata[]
{
PluginController.GetMetadata(typeof(Plugin1Controller)),
@@ -27,7 +27,7 @@ namespace Umbraco.Tests.Web.Controllers
public void Ensure_Same_Area3()
{
Assert.Throws<InvalidOperationException>(() =>
new PluginControllerArea(TestObjects.GetGlobalSettings(),
new PluginControllerArea(TestObjects.GetGlobalSettings(), IOHelper,
new PluginControllerMetadata[]
{
PluginController.GetMetadata(typeof(Plugin1Controller)),
@@ -39,7 +39,7 @@ namespace Umbraco.Tests.Web.Controllers
[Test]
public void Ensure_Same_Area2()
{
var area = new PluginControllerArea(TestObjects.GetGlobalSettings(),
var area = new PluginControllerArea(TestObjects.GetGlobalSettings(), IOHelper,
new PluginControllerMetadata[]
{
PluginController.GetMetadata(typeof(Plugin1Controller)),
@@ -33,7 +33,7 @@ namespace Umbraco.Tests.Web.Mvc
public void SetUp()
{
Current.UmbracoContextAccessor = new TestUmbracoContextAccessor();
Core.Composing.Current.Factory = Mock.Of<IFactory>();
Current.Factory = Mock.Of<IFactory>();
}
[TearDown]
+1 -5
View File
@@ -1,19 +1,15 @@
using System;
using System.IO;
using System.Text;
using Examine.LuceneEngine;
using Lucene.Net.Analysis;
using Lucene.Net.Analysis.Standard;
using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.Web
{
@@ -30,8 +30,8 @@ namespace Umbraco.Web
private readonly IUmbracoDatabaseFactory _databaseFactory;
public BatchedDatabaseServerMessenger(
IRuntimeState runtime, IUmbracoDatabaseFactory databaseFactory, IScopeProvider scopeProvider, ISqlContext sqlContext, IProfilingLogger proflog, DatabaseServerMessengerOptions options, IHostingEnvironment hostingEnvironment)
: base(runtime, scopeProvider, sqlContext, proflog, true, options, hostingEnvironment, Current.CacheRefreshers)
IRuntimeState runtime, IUmbracoDatabaseFactory databaseFactory, IScopeProvider scopeProvider, ISqlContext sqlContext, IProfilingLogger proflog, DatabaseServerMessengerOptions options, IHostingEnvironment hostingEnvironment, CacheRefresherCollection cacheRefreshers)
: base(runtime, scopeProvider, sqlContext, proflog, true, options, hostingEnvironment, cacheRefreshers)
{
_databaseFactory = databaseFactory;
}
+34 -11
View File
@@ -29,8 +29,6 @@ using Umbraco.Web.Routing;
using Umbraco.Web.Services;
using Umbraco.Web.WebApi;
using CoreCurrent = Umbraco.Core.Composing.Current;
namespace Umbraco.Web.Composing
{
// see notes in Umbraco.Core.Composing.Current.
@@ -38,11 +36,30 @@ namespace Umbraco.Web.Composing
{
private static readonly object Locker = new object();
private static IFactory _factory;
/// <summary>
/// Gets or sets the factory.
/// </summary>
public static IFactory Factory
{
get
{
if (_factory == null) throw new InvalidOperationException("No factory has been set.");
return _factory;
}
set
{
if (_factory != null) throw new InvalidOperationException("A factory has already been set.");
_factory = value;
}
}
private static IUmbracoContextAccessor _umbracoContextAccessor;
static Current()
{
CoreCurrent.Resetted += (sender, args) =>
Resetted += (sender, args) =>
{
if (_umbracoContextAccessor != null)
{
@@ -53,17 +70,23 @@ namespace Umbraco.Web.Composing
};
}
// for UNIT TESTS exclusively!
internal static void Reset()
/// <summary>
/// for UNIT TESTS exclusively! Resets <see cref="Current"/>. Indented for testing only, and not supported in production code.
/// </summary>
/// <remarks>
/// <para>For UNIT TESTS exclusively.</para>
/// <para>Resets everything that is 'current'.</para>
/// </remarks>
public static void Reset()
{
CoreCurrent.Reset();
_factory.DisposeIfDisposable();
_factory = null;
Resetted?.Invoke(null, EventArgs.Empty);
}
/// <summary>
/// Gets the factory.
/// </summary>
public static IFactory Factory
=> CoreCurrent.Factory;
internal static event EventHandler Resetted;
#region Temp & Special
@@ -2,10 +2,10 @@
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Manifest;
using Umbraco.Core.Models.ContentEditing;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Web.ContentApps
{
@@ -11,7 +11,7 @@ using System.Xml;
using System.Xml.Linq;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Dictionary;
using Umbraco.Core.Logging;
+2 -5
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
@@ -9,10 +8,8 @@ using System.Text;
using System.Web;
using System.Web.Http;
using Semver;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
using Umbraco.Core.Models.Packaging;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
using Umbraco.Web.WebApi.Filters;
@@ -8,7 +8,7 @@ using System.Web.Http;
using Semver;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.Editors;
@@ -43,7 +43,7 @@ namespace Umbraco.Web.Editors
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, shortStringHelper)
{
_umbracoVersion = umbracoVersion;
}
/// <summary>
@@ -10,6 +10,7 @@ using Umbraco.Core.Logging;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Web.Models.TemplateQuery;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
@@ -34,8 +35,9 @@ namespace Umbraco.Web.Editors
IProfilingLogger logger,
IRuntimeState runtimeState,
UmbracoHelper umbracoHelper,
IVariationContextAccessor variationContextAccessor)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper)
IVariationContextAccessor variationContextAccessor,
IShortStringHelper shortStringHelper)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, shortStringHelper)
{
_variationContextAccessor = variationContextAccessor;
}
@@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -13,6 +13,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
private readonly ConfigurationService _configurationService;
protected ILocalizedTextService TextService { get; }
protected IIOHelper IOHelper { get; }
/// <summary>
/// Gets the config file path.
@@ -52,9 +53,10 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
get { return false; }
}
protected AbstractConfigCheck(ILocalizedTextService textService)
protected AbstractConfigCheck(ILocalizedTextService textService, IIOHelper ioHelper)
{
TextService = textService;
IOHelper = ioHelper;
_configurationService = new ConfigurationService(AbsoluteFilePath, XPath, textService);
}
@@ -66,7 +68,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
/// <summary>
/// Gets the absolute file path.
/// </summary>
private string AbsoluteFilePath => Current.IOHelper.MapPath(FilePath);
private string AbsoluteFilePath => IOHelper.MapPath(FilePath);
/// <summary>
/// Gets the message for when the check has succeeded.
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Umbraco.Core.IO;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -8,8 +9,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Live Environment")]
public class CompilationDebugCheck : AbstractConfigCheck
{
public CompilationDebugCheck(ILocalizedTextService textService)
: base(textService)
public CompilationDebugCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
{ }
public override string FilePath => "~/Web.config";
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -10,8 +11,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Live Environment")]
public class CustomErrorsCheck : AbstractConfigCheck
{
public CustomErrorsCheck(ILocalizedTextService textService)
: base(textService)
public CustomErrorsCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
{ }
public override string FilePath => "~/Web.config";
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.IO;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -9,8 +10,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Configuration")]
public class MacroErrorsCheck : AbstractConfigCheck
{
public MacroErrorsCheck(ILocalizedTextService textService)
: base(textService)
public MacroErrorsCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
{ }
public override string FilePath => "~/Config/umbracoSettings.config";
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Umbraco.Core.IO;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -10,8 +11,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
private const string DefaultFromEmail = "your@email.here";
public NotificationEmailCheck(ILocalizedTextService textService)
: base(textService)
public NotificationEmailCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
{ }
public override string FilePath => "~/Config/umbracoSettings.config";
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Umbraco.Core.IO;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -9,8 +10,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
public class TraceCheck : AbstractConfigCheck
{
public TraceCheck(ILocalizedTextService textService)
: base(textService)
public TraceCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
{ }
public override string FilePath => "~/Web.config";
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Core.IO;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -13,8 +14,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
private readonly Version _serverVersion = HttpRuntime.IISVersion;
public TrySkipIisCustomErrorsCheck(ILocalizedTextService textService)
: base(textService)
public TrySkipIisCustomErrorsCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
{ }
public override string FilePath => "~/Config/umbracoSettings.config";
@@ -7,8 +7,7 @@ using System.Text.RegularExpressions;
using System.Xml.Linq;
using System.Xml.XPath;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Security
@@ -2,11 +2,9 @@
using System.Collections.Generic;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Services;
using Umbraco.Web.HealthCheck.Checks.Config;
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Umbraco.Core;
using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
@@ -18,7 +19,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
private readonly ILogger _logger;
private readonly IGlobalSettings _globalSettings;
public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings)
public EmailNotificationMethod(ILocalizedTextService textService, IRuntimeState runtimeState, ILogger logger, IGlobalSettings globalSettings, IHealthChecks healthChecks): base(healthChecks)
{
var recipientEmail = Settings["recipientEmail"]?.Value;
if (string.IsNullOrWhiteSpace(recipientEmail))
@@ -10,7 +10,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
{
public abstract class NotificationMethodBase : IHealthCheckNotificationMethod
{
protected NotificationMethodBase()
protected NotificationMethodBase(IHealthChecks healthCheckConfig)
{
var type = GetType();
var attribute = type.GetCustomAttribute<HealthCheckNotificationMethodAttribute>();
@@ -20,7 +20,6 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
return;
}
var healthCheckConfig = Current.Configs.HealthChecks();
var notificationMethods = healthCheckConfig.NotificationSettings.NotificationMethods;
var notificationMethod = notificationMethods[attribute.Alias];
if (notificationMethod == null)
@@ -1,16 +1,11 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Umbraco.Core;
using Umbraco.Core.Collections;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
using Umbraco.Web.Install.Models;
namespace Umbraco.Web.Install
@@ -2,8 +2,7 @@
using System.Threading.Tasks;
using System.Web.Configuration;
using System.Xml.Linq;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
using Umbraco.Core.Security;
using Umbraco.Web.Install.Models;
@@ -3,8 +3,7 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
using Umbraco.Web.Install.Models;
namespace Umbraco.Web.Install.InstallSteps
@@ -9,8 +9,7 @@ using System.Xml.Linq;
using ClientDependency.Core.CompositeFiles.Providers;
using ClientDependency.Core.Config;
using Semver;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
namespace Umbraco.Web.JavaScript
+1 -2
View File
@@ -6,10 +6,9 @@ using System.Linq;
using System.Text;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Web.Composing;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Events;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Macros;
using Umbraco.Core.Models;
@@ -7,6 +7,7 @@ using System.Web.SessionState;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Exceptions;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
using Umbraco.Web.WebApi;
@@ -42,6 +43,7 @@ namespace Umbraco.Web.Mvc
/// </remarks>
internal static Route RouteControllerPlugin(this AreaRegistration area,
IGlobalSettings globalSettings,
IIOHelper ioHelper,
string controllerName, Type controllerType, RouteCollection routes,
string controllerSuffixName, string defaultAction, object defaultId,
string umbracoTokenValue = "backoffice",
@@ -57,7 +59,7 @@ namespace Umbraco.Web.Mvc
if (routes == null) throw new ArgumentNullException(nameof(routes));
if (defaultId == null) throw new ArgumentNullException(nameof(defaultId));
var umbracoArea = globalSettings.GetUmbracoMvcArea(Current.IOHelper);
var umbracoArea = globalSettings.GetUmbracoMvcArea(ioHelper);
//routes are explicitly named with controller names and IDs
var url = umbracoArea + "/" +
+6 -3
View File
@@ -1,6 +1,7 @@
using System.Web.Mvc;
using Umbraco.Core.Composing;
using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Web.Editors;
namespace Umbraco.Web.Mvc
@@ -11,10 +12,12 @@ namespace Umbraco.Web.Mvc
internal class BackOfficeArea : AreaRegistration
{
private readonly IGlobalSettings _globalSettings;
private readonly IIOHelper _ioHelper;
public BackOfficeArea(IGlobalSettings globalSettings)
public BackOfficeArea(IGlobalSettings globalSettings, IIOHelper ioHelper)
{
_globalSettings = globalSettings;
_ioHelper = ioHelper;
}
/// <summary>
@@ -48,6 +51,6 @@ namespace Umbraco.Web.Mvc
new[] {typeof (BackOfficeController).Namespace});
}
public override string AreaName => _globalSettings.GetUmbracoMvcArea(Current.IOHelper);
public override string AreaName => _globalSettings.GetUmbracoMvcArea(_ioHelper);
}
}
@@ -7,18 +7,18 @@ namespace Umbraco.Web.Mvc
{
public class ContainerControllerFactory : DefaultControllerFactory
{
private readonly IFactory _container;
private readonly Lazy<IFactory> _factory;
public ContainerControllerFactory(IFactory container)
public ContainerControllerFactory(Lazy<IFactory> factory)
{
_container = container;
_factory = factory;
}
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
try
{
return (IController) _container.GetInstance(controllerType);
return (IController) _factory.Value.GetInstance(controllerType);
}
catch (Exception e)
{
@@ -28,7 +28,7 @@ namespace Umbraco.Web.Mvc
public override void ReleaseController(IController controller)
{
_container.Release(controller);
_factory.Value.Release(controller);
}
}
}
@@ -72,7 +72,7 @@ namespace Umbraco.Web.Mvc
protected UmbracoContext UmbracoContext => _umbracoContextAccessor?.UmbracoContext ?? Current.UmbracoContext;
// TODO: try lazy property injection?
private IPublishedRouter PublishedRouter => Core.Composing.Current.Factory.GetInstance<IPublishedRouter>();
private IPublishedRouter PublishedRouter => Current.Factory.GetInstance<IPublishedRouter>();
/// <summary>
/// Exposes an UmbracoHelper
@@ -2,6 +2,8 @@
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using CSharpTest.Net.Interfaces;
using Umbraco.Core.Composing;
using Umbraco.Web.Composing;
namespace Umbraco.Web.Mvc
@@ -22,7 +24,7 @@ namespace Umbraco.Web.Mvc
/// </summary>
/// <param name="factoriesAccessor">The factories accessor.</param>
public MasterControllerFactory(Func<FilteredControllerFactoryCollection> factoriesAccessor)
: base(Current.Factory)
: base(new Lazy<IFactory>(() => Current.Factory))
{
// note
// because the MasterControllerFactory needs to be ctored to be assigned to
+3 -2
View File
@@ -3,12 +3,13 @@ using System.Collections.Concurrent;
using System.Web.Mvc;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
using Umbraco.Core.Composing;
using Umbraco.Core.Services;
using Umbraco.Web.Security;
using Umbraco.Web.WebApi;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Web.Mvc
{
@@ -22,7 +23,7 @@ namespace Umbraco.Web.Mvc
// for debugging purposes
internal Guid InstanceId { get; } = Guid.NewGuid();
/// <summary>
/// Gets the Umbraco context.
/// </summary>
+7 -4
View File
@@ -6,6 +6,7 @@ using System.Web.Routing;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Web.WebApi;
namespace Umbraco.Web.Mvc
@@ -16,6 +17,7 @@ namespace Umbraco.Web.Mvc
internal class PluginControllerArea : AreaRegistration
{
private readonly IGlobalSettings _globalSettings;
private readonly IIOHelper _ioHelper;
private readonly IEnumerable<PluginControllerMetadata> _surfaceControllers;
private readonly IEnumerable<PluginControllerMetadata> _apiControllers;
private readonly string _areaName;
@@ -26,9 +28,10 @@ namespace Umbraco.Web.Mvc
/// </summary>
/// <param name="globalSettings"></param>
/// <param name="pluginControllers"></param>
public PluginControllerArea(IGlobalSettings globalSettings, IEnumerable<PluginControllerMetadata> pluginControllers)
public PluginControllerArea(IGlobalSettings globalSettings, IIOHelper ioHelper, IEnumerable<PluginControllerMetadata> pluginControllers)
{
_globalSettings = globalSettings;
_ioHelper = ioHelper;
var controllers = pluginControllers.ToArray();
if (controllers.Any(x => x.AreaName.IsNullOrWhiteSpace()))
@@ -67,14 +70,14 @@ namespace Umbraco.Web.Mvc
/// <param name="surfaceControllers"></param>
/// <remarks>
/// The routes will be:
///
///
/// /Umbraco/[AreaName]/[ControllerName]/[Action]/[Id]
/// </remarks>
private void MapRouteSurfaceControllers(RouteCollection routes, IEnumerable<PluginControllerMetadata> surfaceControllers)
{
foreach (var s in surfaceControllers)
{
var route = this.RouteControllerPlugin(_globalSettings, s.ControllerName, s.ControllerType, routes, "", "Index", UrlParameter.Optional, "surface");
var route = this.RouteControllerPlugin(_globalSettings, _ioHelper, s.ControllerName, s.ControllerType, routes, "", "Index", UrlParameter.Optional, "surface");
//set the route handler to our SurfaceRouteHandler
route.RouteHandler = new SurfaceRouteHandler();
}
@@ -89,7 +92,7 @@ namespace Umbraco.Web.Mvc
{
foreach (var s in apiControllers)
{
this.RouteControllerPlugin(_globalSettings, s.ControllerName, s.ControllerType, routes, "", "", UrlParameter.Optional, "api",
this.RouteControllerPlugin(_globalSettings, _ioHelper, s.ControllerName, s.ControllerType, routes, "", "", UrlParameter.Optional, "api",
isMvc: false,
areaPathPrefix: s.IsBackOffice ? "backoffice" : null);
}
+1 -3
View File
@@ -1,9 +1,7 @@
using System.IO;
using System.Linq;
using System.Web.Mvc;
using Lucene.Net.Util;
using Umbraco.Core.Composing;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
namespace Umbraco.Web.Mvc
{
+1 -1
View File
@@ -3,7 +3,7 @@ using System.Web;
using System.Web.Mvc;
using Microsoft.Owin;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Web.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core;
@@ -3,6 +3,7 @@ using System.Web.Mvc;
using System.Web.Routing;
using System.Web.SessionState;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Web.Composing;
namespace Umbraco.Web.Mvc
@@ -68,7 +69,7 @@ namespace Umbraco.Web.Mvc
internal class OverridenDefaultControllerFactory : ContainerControllerFactory
{
public OverridenDefaultControllerFactory()
: base(Current.Factory)
: base(new Lazy<IFactory>(() => Current.Factory))
{ }
public new IController GetControllerInstance(RequestContext requestContext, Type controllerType)
@@ -5,7 +5,7 @@ using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web.Models;
using Umbraco.Web.Routing;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Web.Composing;
namespace Umbraco.Web.Mvc
{
@@ -24,18 +24,21 @@ namespace Umbraco.Web.PropertyEditors
{
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly ILocalizedTextService _localizedTextService;
private readonly IIOHelper _ioHelper;
public ContentPickerPropertyEditor(
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
ILogger logger,
IIOHelper ioHelper,
IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService,Current.Services.TextService, shortStringHelper)
: base(logger, dataTypeService,localizationService,localizedTextService, shortStringHelper)
{
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_localizedTextService = localizedTextService;
_ioHelper = ioHelper;
}
@@ -44,11 +47,11 @@ namespace Umbraco.Web.PropertyEditors
return new ContentPickerConfigurationEditor(_ioHelper);
}
protected override IDataValueEditor CreateValueEditor() => new ContentPickerPropertyValueEditor(_dataTypeService, _localizationService, ShortStringHelper, Attribute);
protected override IDataValueEditor CreateValueEditor() => new ContentPickerPropertyValueEditor(_dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Attribute);
internal class ContentPickerPropertyValueEditor : DataValueEditor, IDataValueReference
{
public ContentPickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) : base(dataTypeService, localizationService,Current.Services.TextService, shortStringHelper, attribute)
public ContentPickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
}
@@ -3,6 +3,7 @@ using Umbraco.Web.Composing;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors
@@ -24,8 +25,8 @@ namespace Umbraco.Web.PropertyEditors
/// Initializes a new instance of the <see cref="DateTimePropertyEditor"/> class.
/// </summary>
/// <param name="logger"></param>
public DateTimePropertyEditor(ILogger logger, IIOHelper ioHelper, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService,Current.Services.TextService, shortStringHelper)
public DateTimePropertyEditor(ILogger logger, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService,localizedTextService, shortStringHelper)
{
_ioHelper = ioHelper;
}
@@ -4,6 +4,7 @@ using Umbraco.Web.Composing;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors
{
@@ -13,8 +14,8 @@ namespace Umbraco.Web.PropertyEditors
/// </summary>
internal class DateValueEditor : DataValueEditor
{
public DateValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute)
: base(dataTypeService, localizationService, Current.Services.TextService, shortStringHelper, attribute)
public DateValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
Validators.Add(new DateTimeValidator());
}
@@ -3,6 +3,7 @@ using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.Validators;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors
@@ -21,8 +22,12 @@ namespace Umbraco.Web.PropertyEditors
/// <summary>
/// Initializes a new instance of the <see cref="DecimalPropertyEditor"/> class.
/// </summary>
public DecimalPropertyEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService,Current.Services.TextService, shortStringHelper)
public DecimalPropertyEditor(ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{ }
/// <inheritdoc />
@@ -4,6 +4,7 @@ using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.Validators;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors
@@ -21,8 +22,14 @@ namespace Umbraco.Web.PropertyEditors
/// <summary>
/// The constructor will setup the property editor based on the attribute if one is found
/// </summary>
public EmailAddressPropertyEditor(ILogger logger, IIOHelper ioHelper, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public EmailAddressPropertyEditor(
ILogger logger,
IIOHelper ioHelper,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_ioHelper = ioHelper;
}
@@ -27,14 +27,16 @@ namespace Umbraco.Web.PropertyEditors
private readonly UploadAutoFillProperties _uploadAutoFillProperties;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly ILocalizedTextService _localizedTextService;
public FileUploadPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSection contentSection, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, Current.Services.TextService, shortStringHelper)
public FileUploadPropertyEditor(ILogger logger, IMediaFileSystem mediaFileSystem, IContentSection contentSection, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_contentSection = contentSection;
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_localizedTextService = localizedTextService;
_uploadAutoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSection);
}
@@ -44,8 +46,8 @@ namespace Umbraco.Web.PropertyEditors
/// <returns>The corresponding property value editor.</returns>
protected override IDataValueEditor CreateValueEditor()
{
var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, ShortStringHelper);
editor.Validators.Add(new UploadFileTypeValidator());
var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper);
editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService));
return editor;
}
@@ -17,8 +17,8 @@ namespace Umbraco.Web.PropertyEditors
{
private readonly IMediaFileSystem _mediaFileSystem;
public FileUploadPropertyValueEditor(DataEditorAttribute attribute, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper)
: base(dataTypeService, localizationService, Current.Services.TextService, shortStringHelper, attribute)
public FileUploadPropertyValueEditor(DataEditorAttribute attribute, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
}
@@ -46,12 +46,13 @@ namespace Umbraco.Web.PropertyEditors
IUmbracoContextAccessor umbracoContextAccessor,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
HtmlImageSourceParser imageSourceParser,
RichTextEditorPastedImages pastedImages,
HtmlLocalLinkParser localLinkParser,
IIOHelper ioHelper,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, Current.Services.TextService, shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_umbracoContextAccessor = umbracoContextAccessor;
_dataTypeService = dataTypeService;
@@ -71,7 +72,7 @@ namespace Umbraco.Web.PropertyEditors
/// Overridden to ensure that the value is validated
/// </summary>
/// <returns></returns>
protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _mediaService, _contentTypeBaseServiceProvider, _umbracoContextAccessor, _logger, _dataTypeService, _localizationService, _imageSourceParser, _pastedImages, _localLinkParser, ShortStringHelper);
protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _mediaService, _contentTypeBaseServiceProvider, _umbracoContextAccessor, _logger, DataTypeService, LocalizationService, LocalizedTextService, _imageSourceParser, _pastedImages, _localLinkParser, ShortStringHelper);
protected override IConfigurationEditor CreateConfigurationEditor() => new GridConfigurationEditor(_ioHelper);
@@ -91,17 +92,18 @@ namespace Umbraco.Web.PropertyEditors
ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
HtmlImageSourceParser imageSourceParser,
RichTextEditorPastedImages pastedImages,
HtmlLocalLinkParser localLinkParser,
IShortStringHelper shortStringHelper)
: base(dataTypeService, localizationService, Current.Services.TextService, shortStringHelper, attribute)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
_umbracoContextAccessor = umbracoContextAccessor;
_imageSourceParser = imageSourceParser;
_pastedImages = pastedImages;
_richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, mediaService, contentTypeBaseServiceProvider, umbracoContextAccessor,logger, dataTypeService, localizationService, shortStringHelper, imageSourceParser, localLinkParser, pastedImages);
_mediaPickerPropertyValueEditor = new MediaPickerPropertyEditor.MediaPickerPropertyValueEditor(dataTypeService, localizationService, shortStringHelper, attribute);
_richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, umbracoContextAccessor, dataTypeService, localizationService, localizedTextService, shortStringHelper, imageSourceParser, localLinkParser, pastedImages);
_mediaPickerPropertyValueEditor = new MediaPickerPropertyEditor.MediaPickerPropertyValueEditor(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute);
}
/// <summary>
@@ -60,7 +60,7 @@ namespace Umbraco.Web.PropertyEditors
/// Creates the corresponding property value editor.
/// </summary>
/// <returns>The corresponding property value editor.</returns>
protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, Logger, _mediaFileSystem, _dataTypeService, _localizationService, ShortStringHelper);
protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, Logger, _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper);
/// <summary>
/// Creates the corresponding preValue editor.
@@ -23,8 +23,8 @@ namespace Umbraco.Web.PropertyEditors
private readonly ILogger _logger;
private readonly IMediaFileSystem _mediaFileSystem;
public ImageCropperPropertyValueEditor(DataEditorAttribute attribute, ILogger logger, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper)
: base(dataTypeService, localizationService, Current.Services.TextService, shortStringHelper, attribute)
public ImageCropperPropertyValueEditor(DataEditorAttribute attribute, ILogger logger, IMediaFileSystem mediaFileSystem, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
@@ -3,6 +3,7 @@ using Umbraco.Web.Composing;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors
@@ -25,8 +26,14 @@ namespace Umbraco.Web.PropertyEditors
/// Initializes a new instance of the <see cref="ListViewPropertyEditor"/> class.
/// </summary>
/// <param name="logger"></param>
public ListViewPropertyEditor(ILogger logger, IIOHelper iioHelper, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public ListViewPropertyEditor(
ILogger logger,
IIOHelper iioHelper,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_iioHelper = iioHelper;
}
@@ -3,6 +3,7 @@ using Umbraco.Web.Composing;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors
@@ -24,8 +25,14 @@ namespace Umbraco.Web.PropertyEditors
/// <summary>
/// Initializes a new instance of the <see cref="MarkdownPropertyEditor"/> class.
/// </summary>
public MarkdownPropertyEditor(ILogger logger, IIOHelper ioHelper, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public MarkdownPropertyEditor(
ILogger logger,
IIOHelper ioHelper,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_ioHelper = ioHelper;
}
@@ -23,8 +23,6 @@ namespace Umbraco.Web.PropertyEditors
Icon = Constants.Icons.MediaImage)]
public class MediaPickerPropertyEditor : DataEditor
{
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
/// <summary>
@@ -39,20 +37,18 @@ namespace Umbraco.Web.PropertyEditors
ILocalizedTextService localizedTextService)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() => new MediaPickerConfigurationEditor(_ioHelper);
protected override IDataValueEditor CreateValueEditor() => new MediaPickerPropertyValueEditor(_dataTypeService, _localizationService, ShortStringHelper, Attribute);
protected override IDataValueEditor CreateValueEditor() => new MediaPickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute);
internal class MediaPickerPropertyValueEditor : DataValueEditor, IDataValueReference
{
public MediaPickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute)
: base(dataTypeService,localizationService, Current.Services.TextService, shortStringHelper,attribute)
public MediaPickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute)
: base(dataTypeService,localizationService, localizedTextService, shortStringHelper,attribute)
{
}
@@ -2,6 +2,7 @@
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors
@@ -15,8 +16,13 @@ namespace Umbraco.Web.PropertyEditors
Icon = Constants.Icons.MemberGroup)]
public class MemberGroupPickerPropertyEditor : DataEditor
{
public MemberGroupPickerPropertyEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public MemberGroupPickerPropertyEditor(
ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{ }
}
}
@@ -2,6 +2,7 @@
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors
@@ -15,8 +16,13 @@ namespace Umbraco.Web.PropertyEditors
Icon = Constants.Icons.Member)]
public class MemberPickerPropertyEditor : DataEditor
{
public MemberPickerPropertyEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public MemberPickerPropertyEditor(
ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{ }
protected override IConfigurationEditor CreateConfigurationEditor() => new MemberPickerConfiguration();
@@ -19,26 +19,22 @@ namespace Umbraco.Web.PropertyEditors
Icon = "icon-page-add")]
public class MultiNodeTreePickerPropertyEditor : DataEditor
{
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
public MultiNodeTreePickerPropertyEditor(ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService,Current.Services.TextService, shortStringHelper)
public MultiNodeTreePickerPropertyEditor(ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IIOHelper ioHelper, IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
}
protected override IConfigurationEditor CreateConfigurationEditor() => new MultiNodePickerConfigurationEditor(_ioHelper);
protected override IDataValueEditor CreateValueEditor() => new MultiNodeTreePickerPropertyValueEditor(_dataTypeService, _localizationService, ShortStringHelper, Attribute);
protected override IDataValueEditor CreateValueEditor() => new MultiNodeTreePickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute);
public class MultiNodeTreePickerPropertyValueEditor : DataValueEditor, IDataValueReference
{
public MultiNodeTreePickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute)
: base(dataTypeService, localizationService, Current.Services.TextService, shortStringHelper, attribute)
public MultiNodeTreePickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
}
@@ -22,22 +22,18 @@ namespace Umbraco.Web.PropertyEditors
{
private readonly IEntityService _entityService;
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
public MultiUrlPickerPropertyEditor(ILogger logger, IEntityService entityService, IPublishedSnapshotAccessor publishedSnapshotAccessor, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, Current.Services.TextService, shortStringHelper, EditorType.PropertyValue)
public MultiUrlPickerPropertyEditor(ILogger logger, IEntityService entityService, IPublishedSnapshotAccessor publishedSnapshotAccessor, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IIOHelper ioHelper, IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper, EditorType.PropertyValue)
{
_entityService = entityService ?? throw new ArgumentNullException(nameof(entityService));
_publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor));
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
}
protected override IConfigurationEditor CreateConfigurationEditor() => new MultiUrlPickerConfigurationEditor(_ioHelper);
protected override IDataValueEditor CreateValueEditor() => new MultiUrlPickerValueEditor(_entityService, _publishedSnapshotAccessor, Logger, _dataTypeService, _localizationService, ShortStringHelper, Attribute);
protected override IDataValueEditor CreateValueEditor() => new MultiUrlPickerValueEditor(_entityService, _publishedSnapshotAccessor, Logger, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute);
}
}
@@ -23,8 +23,8 @@ namespace Umbraco.Web.PropertyEditors
private readonly ILogger _logger;
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
public MultiUrlPickerValueEditor(IEntityService entityService, IPublishedSnapshotAccessor publishedSnapshotAccessor, ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute)
: base(dataTypeService, localizationService, Current.Services.TextService, shortStringHelper, attribute)
public MultiUrlPickerValueEditor(IEntityService entityService, IPublishedSnapshotAccessor publishedSnapshotAccessor, ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
_entityService = entityService ?? throw new ArgumentNullException(nameof(entityService));
_publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor));
@@ -38,7 +38,7 @@ namespace Umbraco.Web.PropertyEditors
/// Initializes a new instance of the <see cref="MultipleTextStringPropertyEditor"/> class.
/// </summary>
public MultipleTextStringPropertyEditor(ILogger logger, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, Current.Services.TextService, shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_ioHelper = ioHelper;
_dataTypeService = dataTypeService;
@@ -60,7 +60,7 @@ namespace Umbraco.Web.PropertyEditors
private readonly ILocalizedTextService _localizedTextService;
public MultipleTextStringPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute)
: base(dataTypeService, localizationService, Current.Services.TextService, shortStringHelper, attribute)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
_localizedTextService = localizedTextService;
}
@@ -30,9 +30,7 @@ namespace Umbraco.Web.PropertyEditors
public class NestedContentPropertyEditor : DataEditor
{
private readonly Lazy<PropertyEditorCollection> _propertyEditors;
private readonly IDataTypeService _dataTypeService;
private readonly IContentTypeService _contentTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
internal const string ContentTypeAliasPropertyKey = "ncContentTypeAlias";
@@ -49,9 +47,7 @@ namespace Umbraco.Web.PropertyEditors
: base (logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_propertyEditors = propertyEditors;
_dataTypeService = dataTypeService;
_contentTypeService = contentTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
}
@@ -66,25 +62,29 @@ namespace Umbraco.Web.PropertyEditors
#region Value Editor
protected override IDataValueEditor CreateValueEditor() => new NestedContentPropertyValueEditor(_dataTypeService, _localizationService, _contentTypeService, ShortStringHelper, Attribute, PropertyEditors);
protected override IDataValueEditor CreateValueEditor() => new NestedContentPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, _contentTypeService, ShortStringHelper, Attribute, PropertyEditors);
internal class NestedContentPropertyValueEditor : DataValueEditor, IDataValueReference
{
private readonly PropertyEditorCollection _propertyEditors;
private readonly IContentTypeService _contentTypeService;
private readonly IDataTypeService _dataTypeService;
private readonly NestedContentValues _nestedContentValues;
private readonly Lazy<Dictionary<string, IContentType>> _contentTypes = new Lazy<Dictionary<string, IContentType>>(() =>
Current.Services.ContentTypeService.GetAll().ToDictionary(c => c.Alias)
);
private readonly Lazy<Dictionary<string, IContentType>> _contentTypes;
public NestedContentPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, IContentTypeService contentTypeService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute, PropertyEditorCollection propertyEditors)
: base(dataTypeService, localizationService, Current.Services.TextService, shortStringHelper, attribute)
public NestedContentPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IContentTypeService contentTypeService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute, PropertyEditorCollection propertyEditors)
: base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute)
{
_propertyEditors = propertyEditors;
_contentTypeService = contentTypeService;
_dataTypeService = dataTypeService;
_nestedContentValues = new NestedContentValues(contentTypeService);
Validators.Add(new NestedContentValidator(propertyEditors, dataTypeService, _nestedContentValues));
_contentTypes = new Lazy<Dictionary<string, IContentType>>(() =>
_contentTypeService.GetAll().ToDictionary(c => c.Alias)
);
}
/// <inheritdoc />
@@ -1,6 +1,7 @@
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors.ParameterEditors
@@ -18,8 +19,13 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors
/// <summary>
/// Initializes a new instance of the <see cref="ContentTypeParameterEditor"/> class.
/// </summary>
public ContentTypeParameterEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService,Current.Services.TextService, shortStringHelper)
public ContentTypeParameterEditor(
ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
// configure
DefaultConfiguration.Add("multiple", false);
@@ -2,6 +2,7 @@
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors.ParameterEditors
@@ -19,8 +20,13 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors
/// <summary>
/// Initializes a new instance of the <see cref="MultipleContentPickerParameterEditor"/> class.
/// </summary>
public MultipleContentPickerParameterEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public MultipleContentPickerParameterEditor(
ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
// configure
DefaultConfiguration.Add("multiPicker", "1");
@@ -1,6 +1,7 @@
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors.ParameterEditors
@@ -12,8 +13,13 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors
"entitypicker")]
public class MultipleContentTypeParameterEditor : DataEditor
{
public MultipleContentTypeParameterEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService,Current.Services.TextService, shortStringHelper)
public MultipleContentTypeParameterEditor(
ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
// configure
DefaultConfiguration.Add("multiple", true);
@@ -2,6 +2,7 @@
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors.ParameterEditors
@@ -20,8 +21,12 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors
/// <summary>
/// Initializes a new instance of the <see cref="MultipleMediaPickerParameterEditor"/> class.
/// </summary>
public MultipleMediaPickerParameterEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public MultipleMediaPickerParameterEditor(ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
DefaultConfiguration.Add("multiPicker", "1");
}
@@ -1,6 +1,7 @@
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors.ParameterEditors
@@ -12,8 +13,13 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors
"entitypicker")]
public class MultiplePropertyGroupParameterEditor : DataEditor
{
public MultiplePropertyGroupParameterEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public MultiplePropertyGroupParameterEditor(
ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
// configure
DefaultConfiguration.Add("multiple", true);
@@ -1,6 +1,7 @@
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors.ParameterEditors
@@ -12,8 +13,12 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors
"entitypicker")]
public class MultiplePropertyTypeParameterEditor : DataEditor
{
public MultiplePropertyTypeParameterEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public MultiplePropertyTypeParameterEditor(ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
// configure
DefaultConfiguration.Add("multiple", "1");
@@ -1,6 +1,7 @@
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors.ParameterEditors
@@ -12,8 +13,13 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors
"entitypicker")]
public class PropertyGroupParameterEditor : DataEditor
{
public PropertyGroupParameterEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public PropertyGroupParameterEditor(
ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
// configure
DefaultConfiguration.Add("multiple", "0");
@@ -1,6 +1,7 @@
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors.ParameterEditors
@@ -12,8 +13,13 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors
"entitypicker")]
public class PropertyTypeParameterEditor : DataEditor
{
public PropertyTypeParameterEditor(ILogger logger, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService,Current.Services.TextService, shortStringHelper)
public PropertyTypeParameterEditor(
ILogger logger,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
// configure
DefaultConfiguration.Add("multiple", "0");
@@ -20,16 +20,20 @@ namespace Umbraco.Web.PropertyEditors
Icon = "icon-target")]
public class RadioButtonsPropertyEditor : DataEditor
{
private readonly ILocalizedTextService _textService;
private readonly IIOHelper _ioHelper;
/// <summary>
/// The constructor will setup the property editor based on the attribute if one is found
/// </summary>
public RadioButtonsPropertyEditor(ILogger logger, ILocalizedTextService textService, IIOHelper ioHelper, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService,Current.Services.TextService, shortStringHelper)
public RadioButtonsPropertyEditor(
ILogger logger,
IIOHelper ioHelper,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService,localizedTextService, shortStringHelper)
{
_textService = textService;
_ioHelper = ioHelper;
}
@@ -37,6 +41,6 @@ namespace Umbraco.Web.PropertyEditors
/// Return a custom pre-value editor
/// </summary>
/// <returns></returns>
protected override IConfigurationEditor CreateConfigurationEditor() => new ValueListConfigurationEditor(_textService, _ioHelper);
protected override IConfigurationEditor CreateConfigurationEditor() => new ValueListConfigurationEditor(LocalizedTextService, _ioHelper);
}
}
@@ -1,8 +1,14 @@
using System.Collections.Generic;
using System.Xml;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration;
using Umbraco.Web.Composing;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Web.Editors;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Mvc;
@@ -15,6 +21,14 @@ namespace Umbraco.Web.PropertyEditors
[PluginController("UmbracoApi")]
public class RichTextPreValueController : UmbracoAuthorizedJsonController
{
private readonly IIOHelper _ioHelper;
public RichTextPreValueController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IShortStringHelper shortStringHelper, IIOHelper ioHelper)
: base(globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper, shortStringHelper)
{
_ioHelper = ioHelper;
}
private static volatile bool _init;
private static readonly object Locker = new object();
private static readonly Dictionary<string, RichTextEditorCommand> Commands = new Dictionary<string, RichTextEditorCommand>();
@@ -40,7 +54,7 @@ namespace Umbraco.Web.PropertyEditors
return config;
}
private static void EnsureInit()
private void EnsureInit()
{
if (_init == false)
@@ -51,7 +65,7 @@ namespace Umbraco.Web.PropertyEditors
{
// Load config
XmlDocument xd = new XmlDocument();
xd.Load(Current.IOHelper.MapPath(SystemFiles.TinyMceConfig));
xd.Load(_ioHelper.MapPath(SystemFiles.TinyMceConfig));
foreach (XmlNode n in xd.DocumentElement.SelectNodes("//command"))
{
@@ -32,13 +32,7 @@ namespace Umbraco.Web.PropertyEditors
private readonly HtmlImageSourceParser _imageSourceParser;
private readonly HtmlLocalLinkParser _localLinkParser;
private readonly RichTextEditorPastedImages _pastedImages;
private readonly IDataTypeService _dataTypeService;
private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
private readonly ILogger _logger;
private readonly IMediaService _mediaService;
private readonly IContentTypeBaseServiceProvider _contentTypeBaseServiceProvider;
private readonly IShortStringHelper _shortStringHelper;
/// <summary>
/// The constructor will setup the property editor based on the attribute if one is found
@@ -62,20 +56,14 @@ namespace Umbraco.Web.PropertyEditors
_imageSourceParser = imageSourceParser;
_localLinkParser = localLinkParser;
_pastedImages = pastedImages;
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_ioHelper = ioHelper;
_logger = logger;
_mediaService = mediaService;
_contentTypeBaseServiceProvider = contentTypeBaseServiceProvider;
_shortStringHelper = shortStringHelper;
}
/// <summary>
/// Create a custom value editor
/// </summary>
/// <returns></returns>
protected override IDataValueEditor CreateValueEditor() => new RichTextPropertyValueEditor(Attribute, _mediaService, _contentTypeBaseServiceProvider, _umbracoContextAccessor, _logger, _dataTypeService, _localizationService, _shortStringHelper, _imageSourceParser, _localLinkParser, _pastedImages);
protected override IDataValueEditor CreateValueEditor() => new RichTextPropertyValueEditor(Attribute, _umbracoContextAccessor, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _imageSourceParser, _localLinkParser, _pastedImages);
protected override IConfigurationEditor CreateConfigurationEditor() => new RichTextConfigurationEditor(_ioHelper);
@@ -91,8 +79,17 @@ namespace Umbraco.Web.PropertyEditors
private readonly HtmlLocalLinkParser _localLinkParser;
private readonly RichTextEditorPastedImages _pastedImages;
public RichTextPropertyValueEditor(DataEditorAttribute attribute, IMediaService mediaService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IUmbracoContextAccessor umbracoContextAccessor, ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, HtmlImageSourceParser imageSourceParser, HtmlLocalLinkParser localLinkParser, RichTextEditorPastedImages pastedImages)
: base(dataTypeService, localizationService,Current.Services.TextService, shortStringHelper, attribute)
public RichTextPropertyValueEditor(
DataEditorAttribute attribute,
IUmbracoContextAccessor umbracoContextAccessor,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper,
HtmlImageSourceParser imageSourceParser,
HtmlLocalLinkParser localLinkParser,
RichTextEditorPastedImages pastedImages)
: base(dataTypeService, localizationService,localizedTextService, shortStringHelper, attribute)
{
_umbracoContextAccessor = umbracoContextAccessor;
_imageSourceParser = imageSourceParser;
@@ -3,6 +3,7 @@ using Umbraco.Web.Composing;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
namespace Umbraco.Web.PropertyEditors
@@ -22,8 +23,14 @@ namespace Umbraco.Web.PropertyEditors
/// <summary>
/// Initializes a new instance of the <see cref="SliderPropertyEditor"/> class.
/// </summary>
public SliderPropertyEditor(ILogger logger, IIOHelper ioHelper, IShortStringHelper shortStringHelper)
: base(logger, Current.Services.DataTypeService, Current.Services.LocalizationService, Current.Services.TextService, shortStringHelper)
public SliderPropertyEditor(
ILogger logger,
IIOHelper ioHelper,
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
IShortStringHelper shortStringHelper)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_ioHelper = ioHelper;
}

Some files were not shown because too many files have changed in this diff Show More