Files
Umbraco-CMS/src/Umbraco.Web/PublishedCache/UmbracoContextPublishedSnapshotAccessor.cs
2017-10-31 12:48:24 +01:00

30 lines
914 B
C#

using System;
namespace Umbraco.Web.PublishedCache
{
public class UmbracoContextPublishedSnapshotAccessor : IPublishedSnapshotAccessor
{
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
public UmbracoContextPublishedSnapshotAccessor(IUmbracoContextAccessor umbracoContextAccessor)
{
_umbracoContextAccessor = umbracoContextAccessor;
}
public IPublishedShapshot PublishedSnapshot
{
get
{
var umbracoContext = _umbracoContextAccessor.UmbracoContext;
if (umbracoContext == null) throw new Exception("The IUmbracoContextAccessor could not provide an UmbracoContext.");
return umbracoContext.PublishedShapshot;
}
set
{
throw new NotSupportedException(); // not ok to set
}
}
}
}