using System;
using System.Collections.Generic;
using Umbraco.Core.Models.PublishedContent;
namespace Umbraco.Core.Models
{
///
/// Represents a cached content.
///
///
/// SD: A replacement for INode which needs to occur since INode doesn't contain the document type alias
/// and INode is poorly formatted with mutable properties (i.e. Lists instead of IEnumerable).
/// Stephan: initially, that was for cached published content only. Now, we're using it also for
/// cached preview (so, maybe unpublished) content. A better name would therefore be ICachedContent, as
/// has been suggested. However, can't change now. Maybe in v7?
///
public interface IPublishedContent
{
#region ContentSet
// Because of http://issues.umbraco.org/issue/U4-1797 and in order to implement
// Index() and methods that derive from it such as IsFirst(), IsLast(), etc... all
// content items must know about their containing content set.
///
/// Gets the content set to which the content belongs.
///
/// The default set consists in the siblings of the content (including the content
/// itself) ordered by sortOrder.
IEnumerable ContentSet { get; }
#endregion
#region ContentType
///
/// Gets the content type.
///
PublishedContentType ContentType { get; }
#endregion
#region Content
int Id { get; }
int TemplateId { get; }
int SortOrder { get; }
string Name { get; }
string UrlName { get; }
string DocumentTypeAlias { get; }
int DocumentTypeId { get; }
string WriterName { get; }
string CreatorName { get; }
int WriterId { get; }
int CreatorId { get; }
string Path { get; }
DateTime CreateDate { get; }
DateTime UpdateDate { get; }
Guid Version { get; }
int Level { get; }
string Url { get; }
///
/// Gets a value indicating whether the content is a content (aka a document) or a media.
///
PublishedItemType ItemType { get; }
///
/// Gets a value indicating whether the content is draft.
///
/// A content is draft when it is the unpublished version of a content, which may
/// have a published version, or not.
bool IsDraft { get; }
///
/// Gets the index of the published content within its current owning content set.
///
/// The index of the published content within its current owning content set.
int GetIndex();
#endregion
#region Tree
///
/// Gets the parent of the content.
///
/// The parent of root content is null.
IPublishedContent Parent { get; }
///
/// Gets the children of the content.
///
/// Children are sorted by their sortOrder.
IEnumerable Children { get; }
#endregion
#region Properties
///
/// Gets the properties of the content.
///
///
/// Contains one IPublishedProperty for each property defined for the content type, including
/// inherited properties. Some properties may have no value.
/// The properties collection of an IPublishedContent instance should be read-only ie it is illegal
/// to add properties to the collection.
///
ICollection Properties { get; }
///
/// Gets a property identified by its alias.
///
/// The property alias.
/// The property identified by the alias.
///
/// If the content type has no property with that alias, including inherited properties, returns null,
/// otherwise return a property -- that may have no value (ie HasValue is false).
/// The alias is case-insensitive.
///
IPublishedProperty GetProperty(string alias);
///
/// Gets a property identified by its alias.
///
/// The property alias.
/// A value indicating whether to navigate the tree upwards until a property with a value is found.
/// The property identified by the alias.
///
/// Navigate the tree upwards and look for a property with that alias and with a value (ie HasValue is true).
/// If found, return the property. If no property with that alias is found, having a value or not, return null. Otherwise
/// return the first property that was found with the alias but had no value (ie HasValue is false).
/// The alias is case-insensitive.
///
IPublishedProperty GetProperty(string alias, bool recurse);
///
/// Gets the value of a property identified by its alias.
///
/// The property alias.
/// The value of the property identified by the alias.
///
/// If GetProperty(alias) is null then returns null else return GetProperty(alias).Value.
/// So if the property has no value, returns the default value for that property type.
/// This one is defined here really because we cannot define index extension methods, but all it should do is:
/// var p = GetProperty(alias); return p == null ? null : p.Value; and nothing else.
/// The recursive syntax (eg "_title") is _not_ supported here.
/// The alias is case-insensitive.
///
object this[string alias] { get; } // todo - should obsolete this[alias] (when?)
#endregion
}
}