1
1
using System ;
2
2
using Newtonsoft . Json ;
3
- using Our . Umbraco . DocTypeGridEditor . Web . Mvc ;
4
- using Umbraco . Core ;
3
+ using Umbraco . Core . Composing ;
5
4
using Umbraco . Core . Sync ;
6
5
using Umbraco . Web . Cache ;
7
6
8
7
namespace Our . Umbraco . DocTypeGridEditor
9
8
{
10
- internal class Bootstrap : ApplicationEventHandler
9
+
10
+ public class Bootstrap : IUserComposer
11
11
{
12
- protected override void ApplicationStarting ( UmbracoApplicationBase umbracoApplication , ApplicationContext applicationContext )
12
+ public void Compose ( Composition composition )
13
13
{
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
+ // }
19
19
20
- protected override void ApplicationStarted ( UmbracoApplicationBase umbracoApplication , ApplicationContext applicationContext )
21
- {
22
20
DataTypeCacheRefresher . CacheUpdated += ( sender , e ) =>
23
21
{
24
22
if ( e . MessageType == MessageType . RefreshByJson )
25
23
{
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 ) } } ) ;
27
26
if ( payload != null )
28
27
{
29
28
foreach ( var item in payload )
30
29
{
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 ) ) ;
33
34
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 ) ) ;
36
39
}
37
40
}
38
41
}
@@ -42,17 +45,20 @@ protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplica
42
45
{
43
46
if ( e . MessageType == MessageType . RefreshByJson )
44
47
{
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 ) } } ) ;
46
50
if ( payload != null )
47
51
{
48
52
foreach ( var item in payload )
49
53
{
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 ) ) ;
52
58
53
59
// NOTE: Unsure how to get the doctype GUID, without hitting the database?
54
60
// 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 (
56
62
"Our.Umbraco.DocTypeGridEditor.Helpers.DocTypeGridEditorHelper.GetContentTypeAliasByGuid_" ) ;
57
63
}
58
64
}
0 commit comments