diff --git a/src/Umbraco.Core/Components/IComponent.cs b/src/Umbraco.Core/Components/IComponent.cs index 5ce9c02060..28ca539387 100644 --- a/src/Umbraco.Core/Components/IComponent.cs +++ b/src/Umbraco.Core/Components/IComponent.cs @@ -4,6 +4,7 @@ /// Represents a component. /// /// + /// Components are created by DI and therefore must have a public constructor. /// All components which are also disposable, will be disposed in reverse /// order, when Umbraco terminates. /// The Dispose method may be invoked more than once, and components diff --git a/src/Umbraco.Core/Components/ManifestWatcherComponent.cs b/src/Umbraco.Core/Components/ManifestWatcherComponent.cs index 4134f6e699..a96dd516e7 100644 --- a/src/Umbraco.Core/Components/ManifestWatcherComponent.cs +++ b/src/Umbraco.Core/Components/ManifestWatcherComponent.cs @@ -6,7 +6,7 @@ using Umbraco.Core.Manifest; namespace Umbraco.Core.Components { - public class ManifestWatcherComponent : IComponent, IDisposable + public sealed class ManifestWatcherComponent : IComponent, IDisposable { // if configured and in debug mode, a ManifestWatcher watches App_Plugins folders for // package.manifest chances and restarts the application on any change diff --git a/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs b/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs index fb4c0ec558..9e61feb15d 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntimeComponent.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.Runtime { public class CoreRuntimeComponent : IComponent { - internal CoreRuntimeComponent(IEnumerable mapperProfiles) + public CoreRuntimeComponent(IEnumerable mapperProfiles) { // mapper profiles have been registered & are created by the container Mapper.Initialize(configuration => diff --git a/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs b/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs index 4d85a01ccc..68199fa873 100644 --- a/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs +++ b/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs @@ -93,13 +93,13 @@ namespace Umbraco.Web.Components public sealed class DatabaseServerRegistrarAndMessengerComponent : IComponent { private object _locker = new object(); - private DatabaseServerRegistrar _registrar; - private BatchedDatabaseServerMessenger _messenger; - private IRuntimeState _runtime; - private ILogger _logger; - private IServerRegistrationService _registrationService; - private BackgroundTaskRunner _touchTaskRunner; - private BackgroundTaskRunner _processTaskRunner; + private readonly DatabaseServerRegistrar _registrar; + private readonly BatchedDatabaseServerMessenger _messenger; + private readonly IRuntimeState _runtime; + private readonly ILogger _logger; + private readonly IServerRegistrationService _registrationService; + private readonly BackgroundTaskRunner _touchTaskRunner; + private readonly BackgroundTaskRunner _processTaskRunner; private bool _started; private IBackgroundTask[] _tasks; private IndexRebuilder _indexRebuilder; diff --git a/src/Umbraco.Web/Logging/WebProfilerComponent.cs b/src/Umbraco.Web/Logging/WebProfilerComponent.cs index d37cfdf88b..418ea66d23 100755 --- a/src/Umbraco.Web/Logging/WebProfilerComponent.cs +++ b/src/Umbraco.Web/Logging/WebProfilerComponent.cs @@ -6,18 +6,9 @@ using Umbraco.Core.Logging; namespace Umbraco.Web.Logging { - internal class WebProfilerComponent : IComponent + internal sealed class WebProfilerComponent : IComponent { - // the profiler is too important to be composed in a component, - // it is composed first thing in WebRuntime.Compose - this component - // only initializes it if needed. - // - //public override void Compose(Composition Composition) - //{ - // composition.Container.RegisterSingleton(); - //} - - private WebProfiler _profiler; + private readonly WebProfiler _profiler; public WebProfilerComponent(IProfiler profiler, ILogger logger, IRuntimeState runtime) { diff --git a/src/Umbraco.Web/PropertyEditors/PropertyEditorsComponent.cs b/src/Umbraco.Web/PropertyEditors/PropertyEditorsComponent.cs index 1b133d29c2..e719a72160 100644 --- a/src/Umbraco.Web/PropertyEditors/PropertyEditorsComponent.cs +++ b/src/Umbraco.Web/PropertyEditors/PropertyEditorsComponent.cs @@ -7,7 +7,7 @@ using Umbraco.Core.Services.Implement; namespace Umbraco.Web.PropertyEditors { - internal class PropertyEditorsComponent : IComponent + internal sealed class PropertyEditorsComponent : IComponent { public PropertyEditorsComponent(PropertyEditorCollection propertyEditors) { diff --git a/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComponent.cs b/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComponent.cs index cdcae49b76..fcb2f016b0 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComponent.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComponent.cs @@ -2,9 +2,9 @@ namespace Umbraco.Web.PublishedCache.NuCache { - public class NuCacheComponent : IComponent + public sealed class NuCacheComponent : IComponent { - public void Initialize(IPublishedSnapshotService service) + public NuCacheComponent(IPublishedSnapshotService service) { // nothing - this just ensures that the service is created at boot time } diff --git a/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs b/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs index fbbdc1129f..3edcce3647 100644 --- a/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs +++ b/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs @@ -12,13 +12,13 @@ using Umbraco.Web.Composing; namespace Umbraco.Web.Redirects { - public class RedirectTrackingComponent : IComponent + public sealed class RedirectTrackingComponent : IComponent { private const string ContextKey1 = "Umbraco.Web.Redirects.RedirectTrackingEventHandler.1"; private const string ContextKey2 = "Umbraco.Web.Redirects.RedirectTrackingEventHandler.2"; private const string ContextKey3 = "Umbraco.Web.Redirects.RedirectTrackingEventHandler.3"; - protected RedirectTrackingComponent() + public RedirectTrackingComponent() { // events are weird // on 'published' we 'could' get the old or the new route depending on event handlers order diff --git a/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs b/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs index a35d381d70..4d31c4a351 100644 --- a/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs +++ b/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs @@ -17,12 +17,10 @@ using Umbraco.Core.Components; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; -using Umbraco.Core.Logging; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Profiling; using Umbraco.Core.Services; using Umbraco.Web.Install; -using Umbraco.Web.Models.ContentEditing; using Umbraco.Web.Mvc; using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; @@ -34,9 +32,9 @@ using Current = Umbraco.Web.Composing.Current; namespace Umbraco.Web.Runtime { - public class WebRuntimeComponent : IComponent + internal sealed class WebRuntimeComponent : IComponent { - internal WebRuntimeComponent( + public WebRuntimeComponent( IRuntimeState runtime, IUmbracoContextAccessor umbracoContextAccessor, SurfaceControllerTypeCollection surfaceControllerTypes, diff --git a/src/Umbraco.Web/Scheduling/SchedulerComponent.cs b/src/Umbraco.Web/Scheduling/SchedulerComponent.cs index c7db6c38b3..efd9d60fe8 100644 --- a/src/Umbraco.Web/Scheduling/SchedulerComponent.cs +++ b/src/Umbraco.Web/Scheduling/SchedulerComponent.cs @@ -4,7 +4,6 @@ using System.Threading; using Umbraco.Core; using Umbraco.Core.Components; using Umbraco.Core.Composing; -using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.HealthChecks; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Logging; diff --git a/src/Umbraco.Web/Search/ExamineComponent.cs b/src/Umbraco.Web/Search/ExamineComponent.cs index 446b3c632a..81543c6dcc 100644 --- a/src/Umbraco.Web/Search/ExamineComponent.cs +++ b/src/Umbraco.Web/Search/ExamineComponent.cs @@ -4,14 +4,11 @@ using System.Globalization; using System.Linq; using System.Threading; using Examine; -using Examine.LuceneEngine.Providers; -using Lucene.Net.Index; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Components; using Umbraco.Core.Logging; using Umbraco.Core.Models; -using Umbraco.Core.PropertyEditors; using Umbraco.Core.Scoping; using Umbraco.Core.Services; using Umbraco.Core.Services.Changes; @@ -22,26 +19,21 @@ using Umbraco.Core.Persistence.DatabaseModelDefinitions; using Umbraco.Web.Scheduling; using System.Threading.Tasks; using Examine.LuceneEngine.Directories; -using Examine.LuceneEngine.Indexing; -using Umbraco.Core.Composing; -using Umbraco.Core.Strings; -using Umbraco.Web.Models.ContentEditing; -using Umbraco.Web.Trees; namespace Umbraco.Web.Search { public sealed class ExamineComponent : IComponent { - private IExamineManager _examineManager; - private IContentValueSetBuilder _contentValueSetBuilder; - private IPublishedContentValueSetBuilder _publishedContentValueSetBuilder; - private IValueSetBuilder _mediaValueSetBuilder; - private IValueSetBuilder _memberValueSetBuilder; + private readonly IExamineManager _examineManager; + private readonly IContentValueSetBuilder _contentValueSetBuilder; + public IPublishedContentValueSetBuilder _publishedContentValueSetBuilder; + private readonly IValueSetBuilder _mediaValueSetBuilder; + private readonly IValueSetBuilder _memberValueSetBuilder; private static bool _disableExamineIndexing = false; private static volatile bool _isConfigured = false; private static readonly object IsConfiguredLocker = new object(); - private IScopeProvider _scopeProvider; - private ServiceContext _services; + private readonly IScopeProvider _scopeProvider; + private readonly ServiceContext _services; private static BackgroundTaskRunner _rebuildOnStartupRunner; private static readonly object RebuildLocker = new object(); @@ -50,7 +42,7 @@ namespace Umbraco.Web.Search // but greater that SafeXmlReaderWriter priority which is 60 private const int EnlistPriority = 80; - internal ExamineComponent(IMainDom mainDom, + public ExamineComponent(IMainDom mainDom, IExamineManager examineManager, IProfilingLogger profilingLogger, IScopeProvider scopeProvider, IUmbracoIndexesCreator indexCreator, IndexRebuilder indexRebuilder, ServiceContext services,