Merge remote-tracking branch 'origin/netcore/dev' into netcore/feature/individual-nuget-pr-assembly
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using Umbraco.Cms.Core.Web;
|
||||
|
||||
33
src/Umbraco.Core/Events/UmbracoRoutedRequest.cs
Normal file
33
src/Umbraco.Core/Events/UmbracoRoutedRequest.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Web;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Notification raised when Umbraco routes a front-end request.
|
||||
/// </summary>
|
||||
public class UmbracoRoutedRequest : INotification
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UmbracoRequestBegin"/> class.
|
||||
/// </summary>
|
||||
public UmbracoRoutedRequest(IUmbracoContext umbracoContext)
|
||||
{
|
||||
if (!umbracoContext.IsFrontEndUmbracoRequest())
|
||||
{
|
||||
throw new InvalidOperationException($"{nameof(UmbracoRoutedRequest)} is only valid for Umbraco front-end requests");
|
||||
}
|
||||
|
||||
UmbracoContext = umbracoContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IUmbracoContext"/>
|
||||
/// </summary>
|
||||
public IUmbracoContext UmbracoContext { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace Umbraco.Cms.Core
|
||||
{
|
||||
private readonly IRequestCache _requestCache;
|
||||
|
||||
// ReSharper disable StaticMemberInGenericType
|
||||
private static readonly object Locker = new object();
|
||||
private static bool _registered;
|
||||
// ReSharper restore StaticMemberInGenericType
|
||||
private readonly object _locker = new object();
|
||||
private readonly bool _registered;
|
||||
|
||||
protected abstract string ItemKey { get; }
|
||||
private string _itemKey;
|
||||
|
||||
protected string ItemKey => _itemKey ??= GetType().FullName;
|
||||
|
||||
// read
|
||||
// http://blog.stephencleary.com/2013/04/implicit-async-context-asynclocal.html
|
||||
@@ -43,20 +43,21 @@ namespace Umbraco.Cms.Core
|
||||
private T NonContextValue
|
||||
{
|
||||
get => CallContext<T>.GetData(ItemKey);
|
||||
set
|
||||
{
|
||||
CallContext<T>.SetData(ItemKey, value);
|
||||
}
|
||||
set => CallContext<T>.SetData(ItemKey, value);
|
||||
}
|
||||
|
||||
protected HybridAccessorBase(IRequestCache requestCache)
|
||||
{
|
||||
_requestCache = requestCache ?? throw new ArgumentNullException(nameof(requestCache));
|
||||
|
||||
lock (Locker)
|
||||
lock (_locker)
|
||||
{
|
||||
// register the itemKey once with SafeCallContext
|
||||
if (_registered) return;
|
||||
if (_registered)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_registered = true;
|
||||
}
|
||||
|
||||
@@ -64,13 +65,20 @@ namespace Umbraco.Cms.Core
|
||||
var itemKey = ItemKey; // virtual
|
||||
SafeCallContext.Register(() =>
|
||||
{
|
||||
var value = CallContext<T>.GetData(itemKey);
|
||||
T value = CallContext<T>.GetData(itemKey);
|
||||
return value;
|
||||
}, o =>
|
||||
{
|
||||
if (o == null) return;
|
||||
var value = o as T;
|
||||
if (value == null) throw new ArgumentException($"Expected type {typeof(T).FullName}, got {o.GetType().FullName}", nameof(o));
|
||||
if (o == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (o is not T value)
|
||||
{
|
||||
throw new ArgumentException($"Expected type {typeof(T).FullName}, got {o.GetType().FullName}", nameof(o));
|
||||
}
|
||||
|
||||
CallContext<T>.SetData(itemKey, value);
|
||||
});
|
||||
}
|
||||
@@ -93,9 +101,13 @@ namespace Umbraco.Cms.Core
|
||||
NonContextValue = value;
|
||||
}
|
||||
else if (value == null)
|
||||
{
|
||||
_requestCache.Remove(ItemKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
_requestCache.Set(ItemKey, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
|
||||
namespace Umbraco.Cms.Core
|
||||
{
|
||||
public class HybridEventMessagesAccessor : HybridAccessorBase<EventMessages>, IEventMessagesAccessor
|
||||
{
|
||||
protected override string ItemKey => "Umbraco.Core.Events.HybridEventMessagesAccessor";
|
||||
|
||||
public HybridEventMessagesAccessor(IRequestCache requestCache)
|
||||
: base(requestCache)
|
||||
{ }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
|
||||
namespace Umbraco.Cms.Core.Models.PublishedContent
|
||||
{
|
||||
@@ -11,9 +11,6 @@ namespace Umbraco.Cms.Core.Models.PublishedContent
|
||||
: base(requestCache)
|
||||
{ }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string ItemKey => "Umbraco.Web.HybridVariationContextAccessor";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="VariationContext"/> object.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
|
||||
namespace Umbraco.Cms.Core.Security
|
||||
{
|
||||
@@ -11,9 +11,6 @@ namespace Umbraco.Cms.Core.Security
|
||||
: base(requestCache)
|
||||
{ }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string ItemKey => "Umbraco.Web.HybridBackofficeSecurityAccessor";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IBackOfficeSecurity"/> object.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
|
||||
namespace Umbraco.Cms.Core.Security
|
||||
{
|
||||
@@ -12,9 +12,6 @@ namespace Umbraco.Cms.Core.Security
|
||||
: base(requestCache)
|
||||
{ }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string ItemKey => "Umbraco.Web.HybridUmbracoWebsiteSecurityAccessor";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IUmbracoWebsiteSecurity"/> object.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Umbraco.Cms.Core
|
||||
namespace Umbraco.Cms.Core.Security
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates and manages <see cref="IBackOfficeSecurity"/> instances.
|
||||
@@ -1,9 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Cms.Core.Models.Security;
|
||||
|
||||
namespace Umbraco.Cms.Core.Security
|
||||
{
|
||||
// TODO: I think we can kill this whole thing, the logic can just be in the controllers
|
||||
public interface IUmbracoWebsiteSecurity
|
||||
{
|
||||
/// <summary>
|
||||
@@ -35,18 +36,10 @@ namespace Umbraco.Cms.Core.Security
|
||||
/// <returns>Result of update profile operation.</returns>
|
||||
Task<UpdateMemberProfileResult> UpdateMemberProfileAsync(ProfileModel model);
|
||||
|
||||
/// <summary>
|
||||
/// A helper method to perform the validation and logging in of a member.
|
||||
/// </summary>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="password">The password.</param>
|
||||
/// <returns>Result of login operation.</returns>
|
||||
// TODO: Kill this, we will just use the MemberManager / MemberSignInManager
|
||||
Task<bool> LoginAsync(string username, string password);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a member is logged in
|
||||
/// </summary>
|
||||
/// <returns>True if logged in, false if not.</returns>
|
||||
// TODO: Kill this, we will just use the MemberManager
|
||||
bool IsLoggedIn();
|
||||
|
||||
/// <summary>
|
||||
@@ -55,9 +48,7 @@ namespace Umbraco.Cms.Core.Security
|
||||
/// <returns>Instance of <see cref="LoginStatusModel"/></returns>
|
||||
Task<LoginStatusModel> GetCurrentLoginStatusAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Logs out the current member.
|
||||
/// </summary>
|
||||
// TODO: Kill this, we will just use the MemberManager
|
||||
Task LogOutAsync();
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>8</LangVersion>
|
||||
<RootNamespace>Umbraco.Cms.Core</RootNamespace>
|
||||
<AssemblyVersion>0.5.0</AssemblyVersion>
|
||||
<InformationalVersion>0.5.0</InformationalVersion>
|
||||
<FileVersion>0.5.0</FileVersion>
|
||||
<Product>Umbraco CMS</Product>
|
||||
<PackageId>Umbraco.Cms.Core</PackageId>
|
||||
<Title>Umbraco CMS Core</Title>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
|
||||
namespace Umbraco.Cms.Core.Web
|
||||
{
|
||||
@@ -14,9 +14,6 @@ namespace Umbraco.Cms.Core.Web
|
||||
: base(requestCache)
|
||||
{ }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string ItemKey => "Umbraco.Web.HybridUmbracoContextAccessor";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="UmbracoContext"/> object.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user