Merge remote-tracking branch 'origin/netcore/dev' into netcore/feature/booting-netcore-db
# Conflicts: # src/Umbraco.Tests.Integration/RuntimeTests.cs # src/Umbraco.Web.BackOffice/AspNetCore/UmbracoBackOfficeServiceCollectionExtensions.cs
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
not want this to happen as the alpha of the next major is, really, the next major already.
|
||||
-->
|
||||
<dependency id="UmbracoCms.Core" version="[$version$]" />
|
||||
<dependency id="ClientDependency" version="[1.9.8,1.999999)" />
|
||||
<dependency id="ClientDependency" version="[1.9.9,1.999999)" />
|
||||
<dependency id="ClientDependency-Mvc5" version="[1.9.3,1.999999)" />
|
||||
<dependency id="Examine" version="[1.0.2,1.999999)" />
|
||||
<dependency id="HtmlAgilityPack" version="[1.8.14,1.999999)" />
|
||||
|
||||
@@ -17,12 +17,18 @@ namespace Umbraco.Core.Composing
|
||||
_container = new LightInjectContainer(container);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an ASP.NET Core compatible service container
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ServiceContainer CreateServiceContainer() => new ServiceContainer(ContainerOptions.Default.Clone().WithMicrosoftSettings().WithAspNetCoreSettings());
|
||||
|
||||
/// <summary>
|
||||
/// Default ctor for use in Host Builder configuration
|
||||
/// </summary>
|
||||
public UmbracoServiceProviderFactory()
|
||||
{
|
||||
var container = new ServiceContainer(ContainerOptions.Default.Clone().WithMicrosoftSettings().WithAspNetCoreSettings());
|
||||
var container = CreateServiceContainer();
|
||||
UmbracoContainer = _container = new LightInjectContainer(container);
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Umbraco.Core.Models
|
||||
/// <summary>
|
||||
/// Represents a property value.
|
||||
/// </summary>
|
||||
public class PropertyValue : IPropertyValue
|
||||
public class PropertyValue : IPropertyValue, IEquatable<PropertyValue>
|
||||
{
|
||||
// TODO: Either we allow change tracking at this class level, or we add some special change tracking collections to the Property
|
||||
// class to deal with change tracking which variants have changed
|
||||
@@ -143,6 +143,27 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
public IPropertyValue Clone()
|
||||
=> new PropertyValue { _culture = _culture, _segment = _segment, PublishedValue = PublishedValue, EditedValue = EditedValue };
|
||||
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return Equals(obj as PropertyValue);
|
||||
}
|
||||
|
||||
public bool Equals(PropertyValue other)
|
||||
{
|
||||
return other != null &&
|
||||
_culture == other._culture &&
|
||||
_segment == other._segment;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
var hashCode = -1254204277;
|
||||
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(_culture);
|
||||
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(_segment);
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly DelegateEqualityComparer<object> PropertyValueComparer = new DelegateEqualityComparer<object>(
|
||||
@@ -508,6 +529,19 @@ namespace Umbraco.Core.Models
|
||||
|
||||
var clonedEntity = (Property)clone;
|
||||
|
||||
//manually clone _values, _pvalue, _vvalues
|
||||
clonedEntity._values = _values?.Select(x => x.Clone()).ToList(); // all values get copied
|
||||
clonedEntity._pvalue = _pvalue?.Clone();
|
||||
// the tricky part here is that _values contains ALL values including the values in the _vvalues
|
||||
// dictionary and they are by reference which is why we have equality overloads on PropertyValue
|
||||
if (clonedEntity._vvalues != null)
|
||||
{
|
||||
clonedEntity._vvalues = new Dictionary<CompositeNStringNStringKey, IPropertyValue>();
|
||||
foreach (var item in _vvalues)
|
||||
{
|
||||
clonedEntity._vvalues[item.Key] = clonedEntity._values.First(x => x.Equals(item.Value));
|
||||
}
|
||||
}
|
||||
//need to manually assign since this is a readonly property
|
||||
clonedEntity.PropertyType = (PropertyType) PropertyType.DeepClone();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Umbraco.Tests.Integration
|
||||
var msdiServiceProvider = services.BuildServiceProvider();
|
||||
|
||||
// LightInject / Umbraco
|
||||
var container = new ServiceContainer(ContainerOptions.Default.Clone().WithMicrosoftSettings().WithAspNetCoreSettings());
|
||||
var container = UmbracoServiceProviderFactory.CreateServiceContainer();
|
||||
var serviceProviderFactory = new UmbracoServiceProviderFactory(container);
|
||||
var umbracoContainer = serviceProviderFactory.GetContainer();
|
||||
serviceProviderFactory.CreateBuilder(services); // called during Host Builder, needed to capture services
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Tests.Integration
|
||||
public void BootCoreRuntime()
|
||||
{
|
||||
// LightInject / Umbraco
|
||||
var container = new ServiceContainer(ContainerOptions.Default.Clone().WithMicrosoftSettings().WithAspNetCoreSettings());
|
||||
var container = UmbracoServiceProviderFactory.CreateServiceContainer();
|
||||
var serviceProviderFactory = new UmbracoServiceProviderFactory(container);
|
||||
var umbracoContainer = serviceProviderFactory.GetContainer();
|
||||
|
||||
|
||||
@@ -1890,6 +1890,49 @@ namespace Umbraco.Tests.Services
|
||||
//Assert.AreNotEqual(content.Name, copy.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Copy_And_Modify_Content_With_Events()
|
||||
{
|
||||
// see https://github.com/umbraco/Umbraco-CMS/issues/5513
|
||||
|
||||
TypedEventHandler<IContentService, CopyEventArgs<IContent>> copying = (sender, args) =>
|
||||
{
|
||||
args.Copy.SetValue("title", "1");
|
||||
args.Original.SetValue("title", "2");
|
||||
};
|
||||
|
||||
TypedEventHandler<IContentService, CopyEventArgs<IContent>> copied = (sender, args) =>
|
||||
{
|
||||
var copyVal = args.Copy.GetValue<string>("title");
|
||||
var origVal = args.Original.GetValue<string>("title");
|
||||
|
||||
Assert.AreEqual("1", copyVal);
|
||||
Assert.AreEqual("2", origVal);
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var contentService = ServiceContext.ContentService;
|
||||
|
||||
ContentService.Copying += copying;
|
||||
ContentService.Copied += copied;
|
||||
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType();
|
||||
ServiceContext.ContentTypeService.Save(contentType);
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
content.SetValue("title", "New Value");
|
||||
contentService.Save(content);
|
||||
|
||||
var copy = contentService.Copy(content, content.ParentId, false, Constants.Security.SuperUserId);
|
||||
Assert.AreEqual("1", copy.GetValue("title"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
ContentService.Copying -= copying;
|
||||
ContentService.Copied -= copied;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Copy_Recursive()
|
||||
{
|
||||
|
||||
@@ -18,10 +18,11 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
{
|
||||
get
|
||||
{
|
||||
var httpContext = _httpContextAccessor?.HttpContext;
|
||||
// If session isn't enabled this will throw an exception so we check
|
||||
var sessionFeature = _httpContextAccessor?.HttpContext?.Features.Get<ISessionFeature>();
|
||||
var sessionFeature = httpContext?.Features.Get<ISessionFeature>();
|
||||
return sessionFeature != null
|
||||
? _httpContextAccessor?.HttpContext?.Session?.Id
|
||||
? httpContext?.Session?.Id
|
||||
: "0";
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -147,10 +147,11 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
ioHelper = new IOHelper(hostingEnvironment, globalSettings);
|
||||
logger = SerilogLogger.CreateWithDefaultConfiguration(hostingEnvironment,
|
||||
new AspNetCoreSessionIdResolver(httpContextAccessor),
|
||||
() => serviceProvider.GetService<IRequestCache>(), coreDebug, ioHelper,
|
||||
// need to build a new service provider since the one already resolved above doesn't have the IRequestCache yet
|
||||
() => services.BuildServiceProvider().GetService<IRequestCache>(), coreDebug, ioHelper,
|
||||
new AspNetCoreMarchal());
|
||||
|
||||
backOfficeInfo = new AspNetCoreBackOfficeInfo(configs.Global());
|
||||
backOfficeInfo = new AspNetCoreBackOfficeInfo(globalSettings);
|
||||
profiler = new LogProfiler(logger);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Web.UI.BackOffice
|
||||
@@ -15,9 +14,8 @@ namespace Umbraco.Web.UI.BackOffice
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); })
|
||||
.UseUmbraco()
|
||||
.UseSerilog();
|
||||
.UseUmbraco();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CSharpTest.Net.Collections" Version="14.906.1403.1082" />
|
||||
<PackageReference Include="ClientDependency" Version="1.9.8" />
|
||||
<PackageReference Include="ClientDependency" Version="1.9.9" />
|
||||
<PackageReference Include="ClientDependency-Mvc5" Version="1.9.3" />
|
||||
<PackageReference Include="ImageProcessor.Web" Version="4.10.0.100" />
|
||||
<PackageReference Include="ImageProcessor.Web.Config" Version="2.5.0.100" />
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ClientDependency" Version="1.9.8" />
|
||||
<PackageReference Include="ClientDependency" Version="1.9.9" />
|
||||
<PackageReference Include="Examine.Core">
|
||||
<Version>2.0.0-alpha.20200128.15</Version>
|
||||
</PackageReference>
|
||||
@@ -585,4 +585,4 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user