Fix missing dependencies errors, simplify
This commit is contained in:
38
src/Umbraco.Core/IMainDom.cs
Normal file
38
src/Umbraco.Core/IMainDom.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the main AppDomain running for a given application.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>There can be only one "main" AppDomain running for a given application at a time.</para>
|
||||
/// <para>It is possible to register against the MainDom and be notified when it is released.</para>
|
||||
/// </remarks>
|
||||
public interface IMainDom
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current domain is the main domain.
|
||||
/// </summary>
|
||||
bool IsMainDom { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Registers a resource that requires the current AppDomain to be the main domain to function.
|
||||
/// </summary>
|
||||
/// <param name="release">An action to execute before the AppDomain releases the main domain status.</param>
|
||||
/// <param name="weight">An optional weight (lower goes first).</param>
|
||||
/// <returns>A value indicating whether it was possible to register.</returns>
|
||||
bool Register(Action release, int weight = 100);
|
||||
|
||||
/// <summary>
|
||||
/// Registers a resource that requires the current AppDomain to be the main domain to function.
|
||||
/// </summary>
|
||||
/// <param name="install">An action to execute when registering.</param>
|
||||
/// <param name="release">An action to execute before the AppDomain releases the main domain status.</param>
|
||||
/// <param name="weight">An optional weight (lower goes first).</param>
|
||||
/// <returns>A value indicating whether it was possible to register.</returns>
|
||||
/// <remarks>If registering is successful, then the <paramref name="install"/> action
|
||||
/// is guaranteed to execute before the AppDomain releases the main domain status.</remarks>
|
||||
bool Register(Action install, Action release, int weight = 100);
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,11 @@ using Umbraco.Core.Logging;
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the main AppDomain running for a given application.
|
||||
/// Provides the full implementation of <see cref="IMainDom"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>There can be only one "main" AppDomain running for a given application at a time.</para>
|
||||
/// <para>When an AppDomain starts, it tries to acquire the main domain status.</para>
|
||||
/// <para>When an AppDomain stops (eg the application is restarting) it should release the main domain status.</para>
|
||||
/// <para>It is possible to register against the MainDom and be notified when it is released.</para>
|
||||
/// </remarks>
|
||||
internal class MainDom : IRegisteredObject
|
||||
{
|
||||
@@ -84,9 +82,7 @@ namespace Umbraco.Core
|
||||
/// <param name="weight">An optional weight (lower goes first).</param>
|
||||
/// <returns>A value indicating whether it was possible to register.</returns>
|
||||
public bool Register(Action release, int weight = 100)
|
||||
{
|
||||
return Register(null, release, weight);
|
||||
}
|
||||
=> Register(null, release, weight);
|
||||
|
||||
/// <summary>
|
||||
/// Registers a resource that requires the current AppDomain to be the main domain to function.
|
||||
@@ -195,7 +191,9 @@ namespace Umbraco.Core
|
||||
}
|
||||
}
|
||||
|
||||
// gets a value indicating whether we are the main domain
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current domain is the main domain.
|
||||
/// </summary>
|
||||
public bool IsMainDom => _isMainDom;
|
||||
|
||||
// IRegisteredObject
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
IEntityService entityService,
|
||||
IUserService userService,
|
||||
IScopeProvider scopeProvider,
|
||||
IEnumerable<IUrlSegmentProvider> urlSegmentProviders,
|
||||
UrlSegmentProviderCollection urlSegmentProviders,
|
||||
IAuditRepository auditRepository, IContentTypeRepository contentTypeRepository,
|
||||
PropertyEditorCollection propertyEditors)
|
||||
{
|
||||
|
||||
59
src/Umbraco.Core/SimpleMainDom.cs
Normal file
59
src/Umbraco.Core/SimpleMainDom.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Umbraco.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a simple implementation of <see cref="IMainDom"/>.
|
||||
/// </summary>
|
||||
public class SimpleMainDom : IMainDom
|
||||
{
|
||||
private readonly object _locko = new object();
|
||||
private readonly List<KeyValuePair<int, Action>> _callbacks = new List<KeyValuePair<int, Action>>();
|
||||
private bool _isStopping;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsMainDom { get; private set; } = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Register(Action release, int weight = 100)
|
||||
=> Register(null, release, weight);
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Register(Action install, Action release, int weight = 100)
|
||||
{
|
||||
lock (_locko)
|
||||
{
|
||||
if (_isStopping) return false;
|
||||
install?.Invoke();
|
||||
if (release != null)
|
||||
_callbacks.Add(new KeyValuePair<int, Action>(weight, release));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
lock (_locko)
|
||||
{
|
||||
if (_isStopping) return;
|
||||
if (IsMainDom == false) return; // probably not needed
|
||||
_isStopping = true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var callback in _callbacks.OrderBy(x => x.Key).Select(x => x.Value))
|
||||
{
|
||||
callback(); // no timeout on callbacks
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// in any case...
|
||||
IsMainDom = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,6 +329,7 @@
|
||||
<Compile Include="Events\ExportedMemberEventArgs.cs" />
|
||||
<Compile Include="Events\RolesEventArgs.cs" />
|
||||
<Compile Include="Events\UserGroupWithUsers.cs" />
|
||||
<Compile Include="IMainDom.cs" />
|
||||
<Compile Include="IO\IFileSystems.cs" />
|
||||
<Compile Include="IO\IMediaFileSystem.cs" />
|
||||
<Compile Include="GuidUtils.cs" />
|
||||
@@ -1431,6 +1432,7 @@
|
||||
<Compile Include="Components\ManifestWatcherComponent.cs" />
|
||||
<Compile Include="Components\RelateOnCopyComponent.cs" />
|
||||
<Compile Include="Components\RelateOnTrashComponent.cs" />
|
||||
<Compile Include="SimpleMainDom.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="Strings\CleanStringType.cs" />
|
||||
<Compile Include="Strings\ContentBaseExtensions.cs" />
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Examine
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public MediaValueSetBuilder(PropertyEditorCollection propertyEditors,
|
||||
IEnumerable<IUrlSegmentProvider> urlSegmentProviders,
|
||||
UrlSegmentProviderCollection urlSegmentProviders,
|
||||
IUserService userService)
|
||||
: base(propertyEditors, false)
|
||||
{
|
||||
|
||||
@@ -136,8 +136,8 @@ Ensure that 'NameSpace.IBar' is registered with a lifetime that is equal to or h
|
||||
{
|
||||
var serviceType = validationTarget.ServiceType.GenericTypeArguments[0];
|
||||
var underlyingvalidationTarget = validationTarget.WithServiceDescription(serviceType, string.Empty);
|
||||
registration = GetServiceRegistration(serviceMap, underlyingvalidationTarget);
|
||||
if (registration != null) return;
|
||||
var registrations = GetServiceRegistrations(serviceMap, underlyingvalidationTarget);
|
||||
if (registrations.Any()) return;
|
||||
|
||||
// strict: there has to be at least 1
|
||||
string message = string.Format(MissingDeferredDependency, validationTarget.ServiceType, underlyingvalidationTarget.ServiceType);
|
||||
@@ -198,9 +198,13 @@ Ensure that 'NameSpace.IBar' is registered with a lifetime that is equal to or h
|
||||
LifeSpans.TryAdd(typeof(TLifetime), lifeSpan);
|
||||
}
|
||||
|
||||
private static IEnumerable<ServiceRegistration> GetServiceRegistrations(ServiceMap serviceMap, ValidationTarget validationTarget)
|
||||
{
|
||||
return serviceMap.Where(x => validationTarget.ServiceType.IsAssignableFrom(x.Key)).SelectMany(x => x.Value.Values);
|
||||
}
|
||||
|
||||
private static ServiceRegistration GetServiceRegistration(ServiceMap serviceMap, ValidationTarget validationTarget)
|
||||
{
|
||||
|
||||
if (!serviceMap.TryGetValue(validationTarget.ServiceType, out var registrations))
|
||||
{
|
||||
return null;
|
||||
@@ -224,8 +228,6 @@ Ensure that 'NameSpace.IBar' is registered with a lifetime that is equal to or h
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static string GetLifetimeName(ILifetime lifetime)
|
||||
{
|
||||
if (lifetime == null)
|
||||
@@ -235,7 +237,6 @@ Ensure that 'NameSpace.IBar' is registered with a lifetime that is equal to or h
|
||||
return lifetime.GetType().Name;
|
||||
}
|
||||
|
||||
|
||||
private static int GetLifespan(ILifetime lifetime)
|
||||
{
|
||||
if (lifetime == null)
|
||||
@@ -248,9 +249,6 @@ Ensure that 'NameSpace.IBar' is registered with a lifetime that is equal to or h
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
public class StandaloneTests
|
||||
{
|
||||
[Test]
|
||||
[Explicit("This test must be run manually")]
|
||||
public void Test()
|
||||
{
|
||||
// this is almost what CoreRuntime does, without
|
||||
@@ -53,9 +54,12 @@ namespace Umbraco.Tests.Runtimes
|
||||
// at that point, CoreRuntime also does
|
||||
//composition.RegisterUnique(mainDom)
|
||||
// we should make it
|
||||
//composition.RegisterUnique<IMainDom>(mainDom)
|
||||
composition.RegisterUnique(Mock.Of<IMainDom>());
|
||||
//composition.RegisterUnique<IMainDom>(new SimpleMainDom());
|
||||
// because some components want to use it
|
||||
// (and then, what would a standalone maindom be?)
|
||||
//
|
||||
// is this an essential thing then??
|
||||
|
||||
// get the components
|
||||
// all of them?
|
||||
@@ -84,13 +88,13 @@ namespace Umbraco.Tests.Runtimes
|
||||
// and then, validate
|
||||
var lightInjectContainer = (LightInject.ServiceContainer) factory.Concrete;
|
||||
var results = lightInjectContainer.Validate().ToList();
|
||||
foreach (var resultGroup in results.GroupBy(x => x.Severity))
|
||||
foreach (var resultGroup in results.GroupBy(x => x.Severity).OrderBy(x => x.Key))
|
||||
foreach (var result in resultGroup)
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"{result.Severity}: {WordWrap(result.Message, 120)}");
|
||||
var target = result.ValidationTarget;
|
||||
Console.Write("\t");
|
||||
Console.Write("\tsvce: ");
|
||||
Console.Write(target.ServiceName);
|
||||
Console.Write(target.DeclaringService.ServiceType);
|
||||
if (!target.DeclaringService.ServiceName.IsNullOrWhiteSpace())
|
||||
@@ -100,13 +104,15 @@ namespace Umbraco.Tests.Runtimes
|
||||
Console.Write("'");
|
||||
}
|
||||
|
||||
Console.Write(" ");
|
||||
Console.Write(" (");
|
||||
if (target.DeclaringService.Lifetime == null)
|
||||
Console.Write("?");
|
||||
else
|
||||
Console.Write(target.DeclaringService.Lifetime.ToString().TrimStart("LightInject."));
|
||||
Console.WriteLine();
|
||||
Console.Write("\t");
|
||||
Console.WriteLine(")");
|
||||
Console.Write("\timpl: ");
|
||||
Console.WriteLine(target.DeclaringService.ImplementingType);
|
||||
Console.Write("\tparm: ");
|
||||
Console.Write(target.Parameter);
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
IGlobalSettings globalSettings,
|
||||
IUmbracoSettingsSection umbracoSettings,
|
||||
IEventMessagesFactory eventMessagesFactory,
|
||||
IEnumerable<IUrlSegmentProvider> urlSegmentProviders,
|
||||
UrlSegmentProviderCollection urlSegmentProviders,
|
||||
TypeLoader typeLoader,
|
||||
IFactory factory = null)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
|
||||
public static MediaIndexPopulator GetMediaIndexRebuilder(PropertyEditorCollection propertyEditors, IMediaService mediaService)
|
||||
{
|
||||
var mediaValueSetBuilder = new MediaValueSetBuilder(propertyEditors, new[] { new DefaultUrlSegmentProvider() }, GetMockUserService());
|
||||
var mediaValueSetBuilder = new MediaValueSetBuilder(propertyEditors, new UrlSegmentProviderCollection(new[] { new DefaultUrlSegmentProvider() }), GetMockUserService());
|
||||
var mediaIndexDataSource = new MediaIndexPopulator(null, mediaService, mediaValueSetBuilder);
|
||||
return mediaIndexDataSource;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
|
||||
if (validator == null)
|
||||
validator = new ContentValueSetValidator(true);
|
||||
|
||||
|
||||
var i = new UmbracoContentIndex(
|
||||
"testIndexer",
|
||||
UmbracoExamineIndex.UmbracoIndexFieldDefinitions,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Web.Install;
|
||||
using Umbraco.Web.Install.InstallSteps;
|
||||
using Umbraco.Web.Install.Models;
|
||||
|
||||
namespace Umbraco.Web.Composing.Composers
|
||||
{
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Mvc;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Web.Macros
|
||||
{
|
||||
/// <summary>
|
||||
/// Controller to render macro content for Parital View Macros
|
||||
/// Controller to render macro content for Partial View Macros
|
||||
/// </summary>
|
||||
[MergeParentContextViewData]
|
||||
[HideFromTypeFinder] // explicitly used: do *not* find and register it!
|
||||
internal class PartialViewMacroController : Controller
|
||||
{
|
||||
private readonly MacroModel _macro;
|
||||
|
||||
@@ -37,15 +37,6 @@ namespace Umbraco.Web.Models.Mapping
|
||||
_userService = userService ?? throw new System.ArgumentNullException(nameof(userService));
|
||||
}
|
||||
|
||||
public MemberTabsAndPropertiesResolver(IUmbracoContextAccessor umbracoContextAccessor, ILocalizedTextService localizedTextService, IEnumerable<string> ignoreProperties, IMemberService memberService, IUserService userService)
|
||||
: base(localizedTextService, ignoreProperties)
|
||||
{
|
||||
_umbracoContextAccessor = umbracoContextAccessor ?? throw new System.ArgumentNullException(nameof(umbracoContextAccessor));
|
||||
_localizedTextService = localizedTextService ?? throw new System.ArgumentNullException(nameof(localizedTextService));
|
||||
_memberService = memberService ?? throw new System.ArgumentNullException(nameof(memberService));
|
||||
_userService = userService ?? throw new System.ArgumentNullException(nameof(userService));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <remarks>Overriden to deal with custom member properties and permissions.</remarks>
|
||||
public override IEnumerable<Tab<ContentPropertyDisplay>> Resolve(IMember source, MemberDisplay destination, IEnumerable<Tab<ContentPropertyDisplay>> destMember, ResolutionContext context)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
IgnoreProperties = ignoreProperties ?? throw new ArgumentNullException(nameof(ignoreProperties));
|
||||
}
|
||||
|
||||
//TODO: This should deserialize to ListViewConfiguration
|
||||
//TODO: This should deserialize to ListViewConfiguration
|
||||
private static int GetTabNumberFromConfig(IDictionary<string, object> listViewConfig)
|
||||
{
|
||||
if (!listViewConfig.TryGetValue("displayAtTabNumber", out var displayTabNum))
|
||||
@@ -139,13 +139,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
public TabsAndPropertiesResolver(ILocalizedTextService localizedTextService)
|
||||
: base(localizedTextService)
|
||||
{
|
||||
}
|
||||
|
||||
public TabsAndPropertiesResolver(ILocalizedTextService localizedTextService, IEnumerable<string> ignoreProperties)
|
||||
: base(localizedTextService, ignoreProperties)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
public virtual IEnumerable<Tab<ContentPropertyDisplay>> Resolve(TSource source, TDestination destination, IEnumerable<Tab<ContentPropertyDisplay>> destMember, ResolutionContext context)
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
//private static int _singletonCheck;
|
||||
|
||||
public PublishedSnapshotService(Options options, MainDom mainDom, IRuntimeState runtime,
|
||||
public PublishedSnapshotService(Options options, IMainDom mainDom, IRuntimeState runtime,
|
||||
ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, IdkMap idkMap,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
|
||||
ILogger logger, IScopeProvider scopeProvider,
|
||||
|
||||
@@ -40,8 +40,7 @@ namespace Umbraco.Web.Routing
|
||||
IContentLastChanceFinder contentLastChanceFinder,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
ServiceContext services,
|
||||
IProfilingLogger proflog,
|
||||
Func<string, IEnumerable<string>> getRolesForLogin = null)
|
||||
IProfilingLogger proflog)
|
||||
{
|
||||
_webRoutingSection = webRoutingSection ?? throw new ArgumentNullException(nameof(webRoutingSection));
|
||||
_contentFinders = contentFinders ?? throw new ArgumentNullException(nameof(contentFinders));
|
||||
@@ -51,7 +50,7 @@ namespace Umbraco.Web.Routing
|
||||
_variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor));
|
||||
_logger = proflog;
|
||||
|
||||
GetRolesForLogin = getRolesForLogin ?? (s => Roles.Provider.GetRolesForUser(s));
|
||||
GetRolesForLogin = s => Roles.Provider.GetRolesForUser(s);
|
||||
}
|
||||
|
||||
// fixme
|
||||
|
||||
Reference in New Issue
Block a user