* Update gitignore * Move csproj * Update project references * Update solutions * Update build scripts * Tests used to share editorconfig with projects in src * Fix broken tests. * Stop copying around .editorconfig merged root one with linting * csharp_style_expression_bodied -> suggestion * Move StyleCop rulesets to matching directories and update shared build properties * Remove legacy build files, update NuGet.cofig and solution files * Restore myget source * Clean up .gitignore * Update .gitignore * Move new test classes to tests after merge * Gitignore + nuget config * Move new test Co-authored-by: Ronald Barendse <ronald@barend.se>
27 lines
961 B
C#
27 lines
961 B
C#
using System.Collections.Concurrent;
|
|
using System.Runtime.CompilerServices;
|
|
using Umbraco.Cms.Core.Web;
|
|
using Umbraco.Web;
|
|
|
|
namespace Umbraco.Tests.LegacyXmlPublishedCache
|
|
{
|
|
static class UmbracoContextCache
|
|
{
|
|
static readonly ConditionalWeakTable<IUmbracoContext, ConcurrentDictionary<string, object>> Caches
|
|
= new ConditionalWeakTable<IUmbracoContext, ConcurrentDictionary<string, object>>();
|
|
|
|
public static ConcurrentDictionary<string, object> Current
|
|
{
|
|
get
|
|
{
|
|
var umbracoContext = Umbraco.Web.Composing.Current.UmbracoContext;
|
|
|
|
// will get or create a value
|
|
// a ConditionalWeakTable is thread-safe
|
|
// does not prevent the context from being disposed, and then the dictionary will be disposed too
|
|
return umbracoContext == null ? null : Caches.GetOrCreateValue(umbracoContext);
|
|
}
|
|
}
|
|
}
|
|
}
|