using System;
using System.Collections.Generic;
namespace Umbraco.Core.Models.PublishedContent
{
//
// we cannot implement strongly-typed content by inheriting from some sort
// 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.
//
///
/// Provides an abstract base class for IPublishedContent implementations that
/// wrap and extend another IPublishedContent.
///
public abstract class PublishedContentWrapped : IPublishedContent
{
private readonly IPublishedContent _content;
///
/// Initialize a new instance of the class
/// with an IPublishedContent instance to wrap.
///
/// The content to wrap.
protected PublishedContentWrapped(IPublishedContent content)
{
_content = content;
}
///
/// Gets the wrapped content.
///
/// The wrapped content, that was passed as an argument to the constructor.
public IPublishedContent Unwrap() => _content;
#region ContentType
///
public virtual PublishedContentType ContentType => _content.ContentType;
#endregion
#region PublishedElement
///
public Guid Key => _content.Key;
#endregion
#region PublishedContent
///
public virtual int Id => _content.Id;
///
public virtual string Name => _content.Name;
///
public virtual string UrlSegment => _content.UrlSegment;
///
public virtual int SortOrder => _content.SortOrder;
///
public virtual int Level => _content.Level;
///
public virtual string Path => _content.Path;
///
public virtual int TemplateId => _content.TemplateId;
///
public virtual int CreatorId => _content.CreatorId;
///
public virtual string CreatorName => _content.CreatorName;
///
public virtual DateTime CreateDate => _content.CreateDate;
///
public virtual int WriterId => _content.WriterId;
///
public virtual string WriterName => _content.WriterName;
///
public virtual DateTime UpdateDate => _content.UpdateDate;
///
public virtual string Url => _content.Url;
///
public virtual string GetUrl(string culture = null) => _content.GetUrl(culture);
///
public PublishedCultureInfo GetCulture(string culture = null) => _content.GetCulture(culture);
///
public IReadOnlyDictionary Cultures => _content.Cultures;
///
public virtual PublishedItemType ItemType => _content.ItemType;
///
public virtual bool IsDraft => _content.IsDraft;
#endregion
#region Tree
///
public virtual IPublishedContent Parent => _content.Parent;
///
public virtual IEnumerable Children => _content.Children;
#endregion
#region Properties
///
public virtual IEnumerable Properties => _content.Properties;
///
public virtual IPublishedProperty GetProperty(string alias)
{
return _content.GetProperty(alias);
}
#endregion
}
}