2016-05-30 19:54:36 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.PublishedCache
|
|
|
|
|
|
{
|
2017-10-31 12:48:24 +01:00
|
|
|
|
public class UmbracoContextPublishedSnapshotAccessor : IPublishedSnapshotAccessor
|
2016-05-30 19:54:36 +02:00
|
|
|
|
{
|
|
|
|
|
|
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
|
|
|
|
|
|
2017-10-31 12:48:24 +01:00
|
|
|
|
public UmbracoContextPublishedSnapshotAccessor(IUmbracoContextAccessor umbracoContextAccessor)
|
2016-05-30 19:54:36 +02:00
|
|
|
|
{
|
|
|
|
|
|
_umbracoContextAccessor = umbracoContextAccessor;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-31 12:48:24 +01:00
|
|
|
|
public IPublishedShapshot PublishedSnapshot
|
2016-05-30 19:54:36 +02:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var umbracoContext = _umbracoContextAccessor.UmbracoContext;
|
|
|
|
|
|
if (umbracoContext == null) throw new Exception("The IUmbracoContextAccessor could not provide an UmbracoContext.");
|
2017-10-31 12:48:24 +01:00
|
|
|
|
return umbracoContext.PublishedShapshot;
|
2016-05-30 19:54:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotSupportedException(); // not ok to set
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|