From 2c39e4251f4b390e00daeb6c8c28f055c8a5ece3 Mon Sep 17 00:00:00 2001 From: "Morten@Thinkpad-X220" Date: Wed, 3 Oct 2012 08:24:23 -0200 Subject: [PATCH] Adds interfaces for IContent, IMedia, IContentBase. Adds interfaces for IContentTypeBase, IContentTypeComposition, IContentType and IMediaType. This includes the inheritance structure for Content and Media, as well as ContentType and MediaType which is basically the same except for Templates and Compositions. --- src/Umbraco.Core/Models/IContent.cs | 56 ++++++++++ src/Umbraco.Core/Models/IContentBase.cs | 105 ++++++++++++++++++ src/Umbraco.Core/Models/IContentType.cs | 20 ++++ src/Umbraco.Core/Models/IContentTypeBase.cs | 77 +++++++++++++ .../Models/IContentTypeComposition.cs | 52 +++++++++ src/Umbraco.Core/Models/IMedia.cs | 20 ++++ src/Umbraco.Core/Models/IMediaType.cs | 10 ++ src/Umbraco.Core/Umbraco.Core.csproj | 7 ++ 8 files changed, 347 insertions(+) create mode 100644 src/Umbraco.Core/Models/IContent.cs create mode 100644 src/Umbraco.Core/Models/IContentBase.cs create mode 100644 src/Umbraco.Core/Models/IContentType.cs create mode 100644 src/Umbraco.Core/Models/IContentTypeBase.cs create mode 100644 src/Umbraco.Core/Models/IContentTypeComposition.cs create mode 100644 src/Umbraco.Core/Models/IMedia.cs create mode 100644 src/Umbraco.Core/Models/IMediaType.cs diff --git a/src/Umbraco.Core/Models/IContent.cs b/src/Umbraco.Core/Models/IContent.cs new file mode 100644 index 0000000000..b391c62e7e --- /dev/null +++ b/src/Umbraco.Core/Models/IContent.cs @@ -0,0 +1,56 @@ +using System; + +namespace Umbraco.Core.Models +{ + /// + /// Defines a Content object + /// + public interface IContent : IContentBase + { + /// + /// Alias of the template used by the Content + /// This is used to override the default one from the ContentType + /// + string Template { get; set; } + + /// + /// Boolean indicating whether the Content is Published or not + /// + bool Published { get; } + + /// + /// Language of the data contained within the Content object + /// + string Language { get; set; } + + /// + /// Gets the Guid Id of the Content's Version + /// + Guid Version { get; } + + /// + /// Gets or Sets the date the Content should be released and thus be published + /// + DateTime? ReleaseDate { get; set; } + + /// + /// Gets or Sets the date the Content should expire and thus be unpublished + /// + DateTime? ExpireDate { get; set; } + + /// + /// Changes the for the current content object + /// + /// New ContentType for this content + /// Leaves PropertyTypes intact after change + void ChangeContentType(IContentType contentType); + + /// + /// Changes the for the current content object and removes PropertyTypes, + /// which are not part of the new ContentType. + /// + /// New ContentType for this content + /// Boolean indicating whether to clear PropertyTypes upon change + void ChangeContentType(IContentType contentType, bool clearProperties); + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Models/IContentBase.cs b/src/Umbraco.Core/Models/IContentBase.cs new file mode 100644 index 0000000000..99d42b5828 --- /dev/null +++ b/src/Umbraco.Core/Models/IContentBase.cs @@ -0,0 +1,105 @@ +using System.Collections.Generic; +using Umbraco.Core.Models.EntityBase; + +namespace Umbraco.Core.Models +{ + /// + /// Defines the base for a Content object with properties that + /// are shared between Content and Media. + /// + public interface IContentBase : IAggregateRoot + { + /// + /// Gets or Sets the Id of the Parent for the Content + /// + int ParentId { get; set; } + + /// + /// Gets or Sets the Name of the Content + /// + string Name { get; set; } + + /// + /// Gets the Url name of the Content + /// + string UrlName { get; } + + /// + /// Gets or Sets the Sort Order of the Content + /// + int SortOrder { get; set; } + + /// + /// Gets or Sets the Level of the Content + /// + int Level { get; set; } + + /// + /// Gets or Sets the Path of the Content + /// + string Path { get; set; } + + /// + /// Id of the user who created the Content + /// + int UserId { get; set; } + + /// + /// Boolean indicating whether this Content is Trashed or not. + /// If Content is Trashed it will be located in the Recyclebin. + /// + bool Trashed { get; } + + /// + /// Integer Id of the default ContentType + /// + int ContentTypeId { get; } + + /// + /// List of properties, which make up all the data available for this Content object + /// + /// Properties are loaded as part of the Content object graph + PropertyCollection Properties { get; set; } + + /// + /// List of PropertyGroups available on this Content object + /// + /// PropertyGroups are kind of lazy loaded as part of the object graph + IEnumerable PropertyGroups { get; } + + /// + /// List of PropertyTypes available on this Content object + /// + /// PropertyTypes are kind of lazy loaded as part of the object graph + IEnumerable PropertyTypes { get; } + + /// + /// Indicates whether the content object has a property with the supplied alias + /// + /// Alias of the PropertyType + /// True if Property with given alias exists, otherwise False + bool HasProperty(string propertyTypeAlias); + + /// + /// Gets the value of a Property + /// + /// Alias of the PropertyType + /// Value as an + object GetValue(string propertyTypeAlias); + + /// + /// Gets the value of a Property + /// + /// Type of the value to return + /// Alias of the PropertyType + /// Value as a + TPassType GetValue(string propertyTypeAlias); + + /// + /// Sets the value of a Property + /// + /// Alias of the PropertyType + /// Value to set for the Property + void SetValue(string propertyTypeAlias, object value); + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Models/IContentType.cs b/src/Umbraco.Core/Models/IContentType.cs new file mode 100644 index 0000000000..3d9282278d --- /dev/null +++ b/src/Umbraco.Core/Models/IContentType.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; + +namespace Umbraco.Core.Models +{ + /// + /// Defines a ContentType, which Content is based on + /// + public interface IContentType : IContentTypeComposition + { + /// + /// Gets or Sets the path to the default Template of the ContentType + /// + string DefaultTemplate { get; set; } + + /// + /// Gets or Sets a list of Template names/paths which are allowed for the ContentType + /// + IEnumerable AllowedTemplates { get; set; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Models/IContentTypeBase.cs b/src/Umbraco.Core/Models/IContentTypeBase.cs new file mode 100644 index 0000000000..93ad407db6 --- /dev/null +++ b/src/Umbraco.Core/Models/IContentTypeBase.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using Umbraco.Core.Models.EntityBase; + +namespace Umbraco.Core.Models +{ + /// + /// Defines the base for a ContentType with properties that + /// are shared between ContentTypes and MediaTypes. + /// + public interface IContentTypeBase : IAggregateRoot + { + /// + /// Gets or Sets the Alias of the ContentType + /// + string Alias { get; set; } + + /// + /// Gets or Sets the Name of the ContentType + /// + string Name { get; set; } + + /// + /// Gets or Sets the Id of Parent of the ContentType + /// + int ParentId { get; set; } + + /// + /// Gets or Sets the Level of the Content + /// + int Level { get; set; } + + /// + /// Gets or Sets the Path of the Content + /// + string Path { get; set; } + + /// + /// Gets or Sets the Description for the ContentType + /// + string Description { get; set; } + + /// + /// Gets or Sets the Sort Order of the ContentType + /// + int SortOrder { get; set; } + + /// + /// Gets or Sets the Icon for the ContentType + /// + string Icon { get; set; } + + /// + /// Gets or Sets the Thumbnail for the ContentType + /// + string Thumbnail { get; set; } + + /// + /// Gets or Sets the Id of the User who created the ContentType + /// + int UserId { get; set; } + + /// + /// Gets or Sets a list of integer Ids of the ContentTypes allowed under the ContentType + /// + IEnumerable AllowedContentTypes { get; set; } + + /// + /// Gets or Sets a collection of Property Groups + /// + PropertyGroupCollection PropertyGroups { get; set; } + + /// + /// Gets an enumerable list of Property Types aggregated for all groups + /// + IEnumerable PropertyTypes { get; } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Models/IContentTypeComposition.cs b/src/Umbraco.Core/Models/IContentTypeComposition.cs new file mode 100644 index 0000000000..5e97d75e6c --- /dev/null +++ b/src/Umbraco.Core/Models/IContentTypeComposition.cs @@ -0,0 +1,52 @@ +using System.Collections.Generic; + +namespace Umbraco.Core.Models +{ + /// + /// Defines the Composition of a ContentType + /// + public interface IContentTypeComposition : IContentTypeBase + { + /// + /// Gets a list of ContentTypes that make up a composition of PropertyGroups and PropertyTypes for the current ContentType + /// + List ContentTypeComposition { get; } + + /// + /// Gets a list of objects from the composition + /// + IEnumerable CompositionPropertyGroups { get; } + + /// + /// Gets a list of objects from the composition + /// + IEnumerable CompositionPropertyTypes { get; } + + /// + /// Adds a new ContentType to the list of composite ContentTypes + /// + /// to add + /// True if ContentType was added, otherwise returns False + bool AddContentType(IContentTypeComposition contentType); + + /// + /// Removes a ContentType with the supplied alias from the the list of composite ContentTypes + /// + /// Alias of a + /// True if ContentType was removed, otherwise returns False + bool RemoveContentType(string alias); + + /// + /// Checks if a ContentType with the supplied alias exists in the list of composite ContentTypes + /// + /// Alias of a + /// True if ContentType with alias exists, otherwise returns False + bool ContentTypeCompositionExists(string alias); + + /// + /// Gets a list of ContentType aliases from the current composition + /// + /// + IEnumerable CompositionAliases(); + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Models/IMedia.cs b/src/Umbraco.Core/Models/IMedia.cs new file mode 100644 index 0000000000..1f1e2c78c7 --- /dev/null +++ b/src/Umbraco.Core/Models/IMedia.cs @@ -0,0 +1,20 @@ +namespace Umbraco.Core.Models +{ + public interface IMedia : IContentBase + { + /// + /// Changes the for the current content object + /// + /// New ContentType for this content + /// Leaves PropertyTypes intact after change + void ChangeContentType(IMediaType contentType); + + /// + /// Changes the for the current content object and removes PropertyTypes, + /// which are not part of the new ContentType. + /// + /// New ContentType for this content + /// Boolean indicating whether to clear PropertyTypes upon change + void ChangeContentType(IMediaType contentType, bool clearProperties); + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Models/IMediaType.cs b/src/Umbraco.Core/Models/IMediaType.cs new file mode 100644 index 0000000000..8d36168015 --- /dev/null +++ b/src/Umbraco.Core/Models/IMediaType.cs @@ -0,0 +1,10 @@ +namespace Umbraco.Core.Models +{ + /// + /// Defines a ContentType, which Media is based on + /// + public interface IMediaType : IContentTypeBase + { + + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 5da4fcda1e..2243896a52 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -99,6 +99,13 @@ + + + + + + +