Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit 74a842a

Browse files
Extremely WIP upgrade to v8
1 parent e7574f8 commit 74a842a

19 files changed

+702
-477
lines changed

src/Our.Umbraco.DocTypeGridEditor/Bootstrap.cs

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
11
using System;
22
using Newtonsoft.Json;
3-
using Our.Umbraco.DocTypeGridEditor.Web.Mvc;
4-
using Umbraco.Core;
3+
using Umbraco.Core.Composing;
54
using Umbraco.Core.Sync;
65
using Umbraco.Web.Cache;
76

87
namespace Our.Umbraco.DocTypeGridEditor
98
{
10-
internal class Bootstrap : ApplicationEventHandler
9+
10+
public class Bootstrap : IUserComposer
1111
{
12-
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
12+
public void Compose(Composition composition)
1313
{
14-
if (DefaultDocTypeGridEditorSurfaceControllerResolver.HasCurrent == false)
15-
{
16-
DefaultDocTypeGridEditorSurfaceControllerResolver.Current = new DefaultDocTypeGridEditorSurfaceControllerResolver();
17-
}
18-
}
14+
// TODO: What is this for?
15+
//if (DefaultDocTypeGridEditorSurfaceControllerResolver.HasCurrent == false)
16+
//{
17+
// DefaultDocTypeGridEditorSurfaceControllerResolver.Current = new DefaultDocTypeGridEditorSurfaceControllerResolver();
18+
//}
1919

20-
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
21-
{
2220
DataTypeCacheRefresher.CacheUpdated += (sender, e) =>
2321
{
2422
if (e.MessageType == MessageType.RefreshByJson)
2523
{
26-
var payload = JsonConvert.DeserializeAnonymousType((string)e.MessageObject, new[] { new { Id = default(int), UniqueId = default(Guid) } });
24+
var payload = JsonConvert.DeserializeAnonymousType((string) e.MessageObject,
25+
new[] {new {Id = default(int), UniqueId = default(Guid)}});
2726
if (payload != null)
2827
{
2928
foreach (var item in payload)
3029
{
31-
applicationContext.ApplicationCache.RuntimeCache.ClearCacheItem(
32-
string.Concat("Our.Umbraco.DocTypeGridEditor.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_", item.UniqueId));
30+
Current.AppCaches.RuntimeCache.ClearByKey(
31+
string.Concat(
32+
"Our.Umbraco.DocTypeGridEditor.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_",
33+
item.UniqueId));
3334

34-
applicationContext.ApplicationCache.RuntimeCache.ClearCacheItem(
35-
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetPreValuesCollectionByDataTypeId_", item.Id));
35+
Current.AppCaches.RuntimeCache.ClearByKey(
36+
string.Concat(
37+
"Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetPreValuesCollectionByDataTypeId_",
38+
item.Id));
3639
}
3740
}
3841
}
@@ -42,17 +45,20 @@ protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplica
4245
{
4346
if (e.MessageType == MessageType.RefreshByJson)
4447
{
45-
var payload = JsonConvert.DeserializeAnonymousType((string)e.MessageObject, new[] { new { Alias = default(string) } });
48+
var payload = JsonConvert.DeserializeAnonymousType((string) e.MessageObject,
49+
new[] {new {Alias = default(string)}});
4650
if (payload != null)
4751
{
4852
foreach (var item in payload)
4953
{
50-
applicationContext.ApplicationCache.RuntimeCache.ClearCacheItem(
51-
string.Concat("Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypesByAlias_", item.Alias));
54+
Current.AppCaches.RuntimeCache.ClearByKey(
55+
string.Concat(
56+
"Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypesByAlias_",
57+
item.Alias));
5258

5359
// NOTE: Unsure how to get the doctype GUID, without hitting the database?
5460
// So we end up clearing the entire cache for this key. [LK:2018-01-30]
55-
applicationContext.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(
61+
Current.AppCaches.RuntimeCache.ClearByKey(
5662
"Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypeAliasByGuid_");
5763
}
5864
}
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
2-
using Umbraco.Core;
32
using Umbraco.Core.Cache;
3+
using Umbraco.Web.Composing;
44
using Umbraco.Core.Services;
55

66
namespace Our.Umbraco.DocTypeGridEditor.Extensions
@@ -9,12 +9,15 @@ internal static class ContentTypeServiceExtensions
99
{
1010
public static string GetAliasByGuid(this IContentTypeService contentTypeService, Guid id)
1111
{
12-
return ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem<string>(
12+
var cache = Current.AppCaches.RequestCache;
13+
14+
return cache.GetCacheItem<string>(
1315
string.Concat("Our.Umbraco.DocTypeGridEditor.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_", id),
14-
() => ApplicationContext.Current
15-
.DatabaseContext
16-
.Database
17-
.ExecuteScalar<string>("SELECT [cmsContentType].[alias] FROM [cmsContentType] INNER JOIN [umbracoNode] ON [cmsContentType].[nodeId] = [umbracoNode].[id] WHERE [umbracoNode].[uniqueID] = @0", id));
16+
() =>
17+
{
18+
using (var scope = Current.ScopeProvider.CreateScope())
19+
return scope.Database.ExecuteScalar<string>("SELECT [cmsContentType].[alias] FROM [cmsContentType] INNER JOIN [umbracoNode] ON [cmsContentType].[nodeId] = [umbracoNode].[id] WHERE [umbracoNode].[uniqueID] = @0", id);
20+
});
1821
}
1922
}
20-
}
23+
}

0 commit comments

Comments
 (0)