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

209 lines
5.9 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
{
//
// This class has two purposes.
//
// - First, 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.
//
// - Second, any time a content is used in a content set obtained from
// IEnumerable<IPublishedContent>.ToContentSet(), it needs to be cloned and extended
// in order to know about its position in the set. This class provides the base
// for implementing such extension.
//
/// <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-06-04 16:22:43 +02:00
protected readonly IPublishedContent WrappedContentInternal;
2013-11-07 17:16:22 +01:00
/// <summary>
/// Initialize a new instance of the <see cref="PublishedContentWrapped"/> class
/// with an <c>IPublishedContent</c> instance to wrap and extend.
/// </summary>
/// <param name="content">The content to wrap and extend.</param>
protected PublishedContentWrapped(IPublishedContent content)
{
2017-06-04 16:22:43 +02:00
WrappedContentInternal = 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>
public IPublishedContent Unwrap()
{
2017-06-04 16:22:43 +02:00
return WrappedContentInternal;
2013-11-07 17:16:22 +01:00
}
#region ContentSet
public virtual IEnumerable<IPublishedContent> ContentSet
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.ContentSet; }
2013-11-07 17:16:22 +01:00
}
#endregion
#region ContentType
2017-06-04 16:22:43 +02:00
public virtual PublishedContentType ContentType { get { return WrappedContentInternal.ContentType; } }
2013-11-07 17:16:22 +01:00
#endregion
#region Content
public virtual int Id
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.Id; }
2013-11-07 17:16:22 +01:00
}
public virtual int TemplateId
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.TemplateId; }
2013-11-07 17:16:22 +01:00
}
public virtual int SortOrder
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.SortOrder; }
2013-11-07 17:16:22 +01:00
}
public virtual string Name
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.Name; }
2013-11-07 17:16:22 +01:00
}
public virtual string UrlName
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.UrlName; }
2013-11-07 17:16:22 +01:00
}
public virtual string DocumentTypeAlias
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.DocumentTypeAlias; }
2013-11-07 17:16:22 +01:00
}
public virtual int DocumentTypeId
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.DocumentTypeId; }
2013-11-07 17:16:22 +01:00
}
public virtual string WriterName
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.WriterName; }
2013-11-07 17:16:22 +01:00
}
public virtual string CreatorName
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.CreatorName; }
2013-11-07 17:16:22 +01:00
}
public virtual int WriterId
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.WriterId; }
2013-11-07 17:16:22 +01:00
}
public virtual int CreatorId
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.CreatorId; }
2013-11-07 17:16:22 +01:00
}
public virtual string Path
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.Path; }
2013-11-07 17:16:22 +01:00
}
public virtual DateTime CreateDate
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.CreateDate; }
2013-11-07 17:16:22 +01:00
}
public virtual DateTime UpdateDate
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.UpdateDate; }
2013-11-07 17:16:22 +01:00
}
public virtual Guid Version
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.Version; }
2013-11-07 17:16:22 +01:00
}
public virtual int Level
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.Level; }
2013-11-07 17:16:22 +01:00
}
public virtual string Url
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.Url; }
2013-11-07 17:16:22 +01:00
}
public virtual PublishedItemType ItemType
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.ItemType; }
2013-11-07 17:16:22 +01:00
}
public virtual bool IsDraft
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.IsDraft; }
2013-11-07 17:16:22 +01:00
}
public virtual int GetIndex()
{
2017-06-04 16:22:43 +02:00
return WrappedContentInternal.GetIndex();
2013-11-07 17:16:22 +01:00
}
#endregion
#region Tree
public virtual IPublishedContent Parent
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.Parent; }
2013-11-07 17:16:22 +01:00
}
public virtual IEnumerable<IPublishedContent> Children
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.Children; }
2013-11-07 17:16:22 +01:00
}
#endregion
#region Properties
public virtual ICollection<IPublishedProperty> Properties
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal.Properties; }
2013-11-07 17:16:22 +01:00
}
public virtual object this[string alias]
{
2017-06-04 16:22:43 +02:00
get { return WrappedContentInternal[alias]; }
2013-11-07 17:16:22 +01:00
}
public virtual IPublishedProperty GetProperty(string alias)
{
2017-06-04 16:22:43 +02:00
return WrappedContentInternal.GetProperty(alias);
2013-11-07 17:16:22 +01:00
}
public virtual IPublishedProperty GetProperty(string alias, bool recurse)
{
2017-06-04 16:22:43 +02:00
return WrappedContentInternal.GetProperty(alias, recurse);
2013-11-07 17:16:22 +01:00
}
#endregion
}
}