Files
Umbraco-CMS/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs

116 lines
3.7 KiB
C#
Raw Normal View History

2013-11-07 17:16:22 +01:00
using System;
using System.Collections.Generic;
namespace Umbraco.Core.Models.PublishedContent
{
//
2017-07-21 17:04:14 +02:00
// we cannot implement strongly-typed content by inheriting from some sort
2013-11-07 17:16:22 +01:00
// of "master content" because that master content depends on the actual content cache
// that is being used. It can be an XmlPublishedContent with the XmlPublishedCache,
// or just anything else.
//
// So we implement strongly-typed content by encapsulating whatever content is
// returned by the content cache, and providing extra properties (mostly) or
// methods or whatever. This class provides the base for such encapsulation.
//
/// <summary>
/// Provides an abstract base class for <c>IPublishedContent</c> implementations that
/// wrap and extend another <c>IPublishedContent</c>.
/// </summary>
public abstract class PublishedContentWrapped : IPublishedContent
{
2017-08-24 21:24:14 +02:00
private readonly IPublishedContent _content;
2013-11-07 17:16:22 +01:00
/// <summary>
/// Initialize a new instance of the <see cref="PublishedContentWrapped"/> class
2017-07-21 17:04:14 +02:00
/// with an <c>IPublishedContent</c> instance to wrap.
2013-11-07 17:16:22 +01:00
/// </summary>
2017-07-21 17:04:14 +02:00
/// <param name="content">The content to wrap.</param>
2013-11-07 17:16:22 +01:00
protected PublishedContentWrapped(IPublishedContent content)
{
2017-08-24 21:24:14 +02:00
_content = content;
2013-11-07 17:16:22 +01:00
}
/// <summary>
/// Gets the wrapped content.
/// </summary>
/// <returns>The wrapped content, that was passed as an argument to the constructor.</returns>
2017-08-24 21:24:14 +02:00
public IPublishedContent Unwrap() => _content;
2013-11-07 17:16:22 +01:00
#region ContentType
2017-08-24 21:24:14 +02:00
public virtual PublishedContentType ContentType => _content.ContentType;
2013-11-07 17:16:22 +01:00
#endregion
#region Content
2017-08-24 21:24:14 +02:00
public virtual int Id => _content.Id;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public Guid Key => _content.Key;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual int TemplateId => _content.TemplateId;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual int SortOrder => _content.SortOrder;
2013-11-07 17:16:22 +01:00
public virtual string Name => _content.Name;
public virtual IReadOnlyDictionary<string, PublishedCultureName> CultureNames => _content.CultureNames;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual string UrlName => _content.UrlName;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual string DocumentTypeAlias => _content.DocumentTypeAlias;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual int DocumentTypeId => _content.DocumentTypeId;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual string WriterName => _content.WriterName;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual string CreatorName => _content.CreatorName;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual int WriterId => _content.WriterId;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual int CreatorId => _content.CreatorId;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual string Path => _content.Path;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual DateTime CreateDate => _content.CreateDate;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual DateTime UpdateDate => _content.UpdateDate;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual int Level => _content.Level;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual string Url => _content.Url;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual PublishedItemType ItemType => _content.ItemType;
2017-08-24 21:24:14 +02:00
public virtual bool IsDraft => _content.IsDraft;
2013-11-07 17:16:22 +01:00
#endregion
#region Tree
2017-08-24 21:24:14 +02:00
public virtual IPublishedContent Parent => _content.Parent;
2013-11-07 17:16:22 +01:00
2017-08-24 21:24:14 +02:00
public virtual IEnumerable<IPublishedContent> Children => _content.Children;
2013-11-07 17:16:22 +01:00
#endregion
#region Properties
2017-08-24 21:24:14 +02:00
public virtual IEnumerable<IPublishedProperty> Properties => _content.Properties;
2013-11-07 17:16:22 +01:00
public virtual IPublishedProperty GetProperty(string alias)
{
2017-08-24 21:24:14 +02:00
return _content.GetProperty(alias);
2013-11-07 17:16:22 +01:00
}
public virtual IPublishedProperty GetProperty(string alias, bool recurse)
{
2017-08-24 21:24:14 +02:00
return _content.GetProperty(alias, recurse);
2013-11-07 17:16:22 +01:00
}
#endregion
}
}