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

116 lines
3.6 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
{
protected readonly IPublishedContent Content;
/// <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)
{
Content = content;
}
/// <summary>
/// Gets the wrapped content.
/// </summary>
/// <returns>The wrapped content, that was passed as an argument to the constructor.</returns>
2017-07-21 17:04:14 +02:00
public IPublishedContent Unwrap() => Content;
2013-11-07 17:16:22 +01:00
#region ContentType
public virtual PublishedContentType ContentType => Content.ContentType;
2013-11-07 17:16:22 +01:00
#endregion
#region Content
public virtual int Id => Content.Id;
2013-11-07 17:16:22 +01:00
public Guid Key => Content.Key;
2013-11-07 17:16:22 +01:00
public virtual int TemplateId => Content.TemplateId;
2013-11-07 17:16:22 +01:00
public virtual int SortOrder => Content.SortOrder;
2013-11-07 17:16:22 +01:00
public virtual string Name => Content.Name;
2013-11-07 17:16:22 +01:00
public virtual string UrlName => Content.UrlName;
2013-11-07 17:16:22 +01:00
public virtual string DocumentTypeAlias => Content.DocumentTypeAlias;
2013-11-07 17:16:22 +01:00
public virtual int DocumentTypeId => Content.DocumentTypeId;
2013-11-07 17:16:22 +01:00
public virtual string WriterName => Content.WriterName;
2013-11-07 17:16:22 +01:00
public virtual string CreatorName => Content.CreatorName;
2013-11-07 17:16:22 +01:00
public virtual int WriterId => Content.WriterId;
2013-11-07 17:16:22 +01:00
public virtual int CreatorId => Content.CreatorId;
2013-11-07 17:16:22 +01:00
public virtual string Path => Content.Path;
2013-11-07 17:16:22 +01:00
public virtual DateTime CreateDate => Content.CreateDate;
2013-11-07 17:16:22 +01:00
public virtual DateTime UpdateDate => Content.UpdateDate;
2013-11-07 17:16:22 +01:00
public virtual Guid Version => Content.Version;
2013-11-07 17:16:22 +01:00
public virtual int Level => Content.Level;
2013-11-07 17:16:22 +01:00
public virtual string Url => Content.Url;
2013-11-07 17:16:22 +01:00
public virtual PublishedItemType ItemType => Content.ItemType;
public virtual bool IsDraft => Content.IsDraft;
2013-11-07 17:16:22 +01:00
#endregion
#region Tree
public virtual IPublishedContent Parent => Content.Parent;
2013-11-07 17:16:22 +01:00
public virtual IEnumerable<IPublishedContent> Children => Content.Children;
2013-11-07 17:16:22 +01:00
#endregion
#region Properties
public virtual IEnumerable<IPublishedProperty> Properties => Content.Properties;
2013-11-07 17:16:22 +01:00
public virtual IPublishedProperty GetProperty(string alias)
{
return Content.GetProperty(alias);
}
public virtual IPublishedProperty GetProperty(string alias, bool recurse)
{
return Content.GetProperty(alias, recurse);
}
#endregion
}
}