From 62c69edf02c7f5a0f6003fbbd8ccdfdb4bbf7027 Mon Sep 17 00:00:00 2001 From: "Morten@Thinkpad-X220" Date: Tue, 9 Oct 2012 09:49:55 -0200 Subject: [PATCH] Moving public interfaces for a cleaner structure in the .Core project. --- src/Umbraco.Core/Models/ContentType.cs | 4 +- src/Umbraco.Core/Models/Media.cs | 12 + src/Umbraco.Core/Models/MediaType.cs | 251 ++++++++++++++++++ .../{ => Interfaces}/IContentRepository.cs | 0 .../IContentTypeRepository.cs | 0 .../IDataTypeDefinitionRepository.cs | 0 .../{ => Interfaces}/IDictionaryRepository.cs | 0 .../{ => Interfaces}/ILanguageRepository.cs | 0 .../{ => Interfaces}/IMacroRepository.cs | 0 .../Interfaces/IMediaRepository.cs | 9 + .../Interfaces/IMediaTypeRepository.cs | 9 + .../{ => Interfaces}/IRelationRepository.cs | 0 .../IRelationTypeRepository.cs | 0 .../{ => Interfaces}/IRepository.cs | 0 .../{ => Interfaces}/IRepositoryQueryable.cs | 0 .../{ => Interfaces}/IScriptRepository.cs | 0 .../{ => Interfaces}/IStylesheetRepository.cs | 0 .../{ => Interfaces}/ITemplateRepository.cs | 0 src/Umbraco.Core/Umbraco.Core.csproj | 29 +- 19 files changed, 300 insertions(+), 14 deletions(-) create mode 100644 src/Umbraco.Core/Models/MediaType.cs rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IContentRepository.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IContentTypeRepository.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IDataTypeDefinitionRepository.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IDictionaryRepository.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/ILanguageRepository.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IMacroRepository.cs (100%) create mode 100644 src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaRepository.cs create mode 100644 src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaTypeRepository.cs rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IRelationRepository.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IRelationTypeRepository.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IRepository.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IRepositoryQueryable.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IScriptRepository.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/IStylesheetRepository.cs (100%) rename src/Umbraco.Core/Persistence/Repositories/{ => Interfaces}/ITemplateRepository.cs (100%) diff --git a/src/Umbraco.Core/Models/ContentType.cs b/src/Umbraco.Core/Models/ContentType.cs index 623334d0e8..357be601fd 100644 --- a/src/Umbraco.Core/Models/ContentType.cs +++ b/src/Umbraco.Core/Models/ContentType.cs @@ -9,7 +9,7 @@ using Umbraco.Core.Models.EntityBase; namespace Umbraco.Core.Models { /// - /// Represents the type of a object + /// Represents the contnet type that a object is based on /// [Serializable] [DataContract(IsReference = true)] @@ -247,6 +247,7 @@ namespace Umbraco.Core.Models /// /// Gets or sets a list of integer Ids for allowed ContentTypes /// + [DataMember] public IEnumerable AllowedContentTypes { get { return _allowedContentTypes; } @@ -285,6 +286,7 @@ namespace Umbraco.Core.Models /// /// List of ContentTypes that make up a composition of PropertyGroups and PropertyTypes for the current ContentType /// + [DataMember] public List ContentTypeComposition { get { return _contentTypeComposition; } diff --git a/src/Umbraco.Core/Models/Media.cs b/src/Umbraco.Core/Models/Media.cs index 7040d631e2..870d42e517 100644 --- a/src/Umbraco.Core/Models/Media.cs +++ b/src/Umbraco.Core/Models/Media.cs @@ -70,6 +70,7 @@ namespace Umbraco.Core.Models /// /// Gets or Sets the Id of the Parent for the Media /// + [DataMember] public int ParentId { get { return _parentId; } @@ -83,6 +84,7 @@ namespace Umbraco.Core.Models /// /// Gets or Sets the Name of the Media /// + [DataMember] public string Name { get { return _name; } @@ -96,6 +98,7 @@ namespace Umbraco.Core.Models /// /// Gets the Url name of the Media item /// + [IgnoreDataMember] public string UrlName { //TODO: Should return the relative path to the media - if it should be implemented at all @@ -109,6 +112,7 @@ namespace Umbraco.Core.Models /// /// Gets or Sets the Sort Order of the Media /// + [DataMember] public int SortOrder { get { return _sortOrder; } @@ -122,6 +126,7 @@ namespace Umbraco.Core.Models /// /// Gets or Sets the Level of the Media /// + [DataMember] public int Level { get { return _level; } @@ -135,6 +140,7 @@ namespace Umbraco.Core.Models /// /// Gets or Sets the Path of the Media /// + [DataMember] public string Path { get { return _path; } @@ -148,6 +154,7 @@ namespace Umbraco.Core.Models /// /// Id of the user who created the Media /// + [DataMember] public int UserId { get { return _userId; } @@ -162,6 +169,7 @@ namespace Umbraco.Core.Models /// Boolean indicating whether this Media is Trashed or not. /// If Media is Trashed it will be located in the Recyclebin. /// + [DataMember] public bool Trashed { get { return _trashed; } @@ -175,6 +183,7 @@ namespace Umbraco.Core.Models /// /// Integer Id of the default MediaType /// + [DataMember] public int ContentTypeId { get { return _contentTypeId; } @@ -188,6 +197,7 @@ namespace Umbraco.Core.Models /// /// List of properties, which make up all the data available for this Media object /// + [DataMember] public PropertyCollection Properties { get { return _properties; } @@ -201,6 +211,7 @@ namespace Umbraco.Core.Models /// /// List of PropertyGroups available on this Media object /// + [IgnoreDataMember] public IEnumerable PropertyGroups { get { return _contentType.PropertyGroups; } @@ -209,6 +220,7 @@ namespace Umbraco.Core.Models /// /// List of PropertyTypes available on this Media object /// + [IgnoreDataMember] public IEnumerable PropertyTypes { get { return _contentType.PropertyTypes; } diff --git a/src/Umbraco.Core/Models/MediaType.cs b/src/Umbraco.Core/Models/MediaType.cs new file mode 100644 index 0000000000..4bdf37bfb5 --- /dev/null +++ b/src/Umbraco.Core/Models/MediaType.cs @@ -0,0 +1,251 @@ +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.Reflection; +using System.Runtime.Serialization; +using Umbraco.Core.Models.EntityBase; + +namespace Umbraco.Core.Models +{ + /// + /// Represents the content type that a object is based on + /// + [Serializable] + [DataContract(IsReference = true)] + public class MediaType : Entity, IMediaType + { + private int _parentId; + private string _name; + private int _level; + private string _path; + private string _alias; + private string _description; + private int _sortOrder; + private string _icon; + private string _thumbnail; + private int _userId; + private bool _trashed; + private PropertyGroupCollection _propertyGroups; + private IEnumerable _allowedContentTypes; + + public MediaType() + { + _allowedContentTypes = new List(); + _propertyGroups = new PropertyGroupCollection(); + } + + private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo(x => x.Name); + private static readonly PropertyInfo ParentIdSelector = ExpressionHelper.GetPropertyInfo(x => x.ParentId); + private static readonly PropertyInfo SortOrderSelector = ExpressionHelper.GetPropertyInfo(x => x.SortOrder); + private static readonly PropertyInfo LevelSelector = ExpressionHelper.GetPropertyInfo(x => x.Level); + private static readonly PropertyInfo PathSelector = ExpressionHelper.GetPropertyInfo(x => x.Path); + private static readonly PropertyInfo AliasSelector = ExpressionHelper.GetPropertyInfo(x => x.Alias); + private static readonly PropertyInfo DescriptionSelector = ExpressionHelper.GetPropertyInfo(x => x.Description); + private static readonly PropertyInfo IconSelector = ExpressionHelper.GetPropertyInfo(x => x.Icon); + private static readonly PropertyInfo ThumbnailSelector = ExpressionHelper.GetPropertyInfo(x => x.Thumbnail); + private static readonly PropertyInfo UserIdSelector = ExpressionHelper.GetPropertyInfo(x => x.UserId); + private static readonly PropertyInfo TrashedSelector = ExpressionHelper.GetPropertyInfo(x => x.Trashed); + private static readonly PropertyInfo AllowedContentTypesSelector = ExpressionHelper.GetPropertyInfo>(x => x.AllowedContentTypes); + private readonly static PropertyInfo PropertyGroupCollectionSelector = ExpressionHelper.GetPropertyInfo(x => x.PropertyGroups); + void PropertyGroupsChanged(object sender, NotifyCollectionChangedEventArgs e) + { + OnPropertyChanged(PropertyGroupCollectionSelector); + } + + /// + /// Gets or sets the Id of the Parent entity + /// + /// Might not be necessary if handled as a relation? + [DataMember] + public int ParentId + { + get { return _parentId; } + set + { + _parentId = value; + OnPropertyChanged(ParentIdSelector); + } + } + + /// + /// Gets or sets the name of the current entity + /// + [DataMember] + public string Name + { + get { return _name; } + set + { + _name = value; + OnPropertyChanged(NameSelector); + } + } + + /// + /// Gets or sets the level of the content entity + /// + [DataMember] + public int Level //NOTE Is this relevant for a ContentType? + { + get { return _level; } + set + { + _level = value; + OnPropertyChanged(LevelSelector); + } + } + + /// + /// Gets of sets the path + /// + [DataMember] + public string Path //NOTE Is this relevant for a ContentType? + { + get { return _path; } + set + { + _path = value; + OnPropertyChanged(PathSelector); + } + } + + /// + /// The Alias of the ContentType + /// + [DataMember] + public string Alias + { + get { return _alias; } + set + { + _alias = value; + OnPropertyChanged(AliasSelector); + } + } + + /// + /// Description for the ContentType + /// + [DataMember] + public string Description + { + get { return _description; } + set + { + _description = value; + OnPropertyChanged(DescriptionSelector); + } + } + + /// + /// Gets or sets the sort order of the content entity + /// + [DataMember] + public int SortOrder + { + get { return _sortOrder; } + set + { + _sortOrder = value; + OnPropertyChanged(SortOrderSelector); + } + } + + /// + /// Name of the icon (sprite class) used to identify the ContentType + /// + [DataMember] + public string Icon + { + get { return _icon; } + set + { + _icon = value; + OnPropertyChanged(IconSelector); + } + } + + /// + /// Name of the thumbnail used to identify the ContentType + /// + [DataMember] + public string Thumbnail + { + get { return _thumbnail; } + set + { + _thumbnail = value; + OnPropertyChanged(ThumbnailSelector); + } + } + + /// + /// Id of the user who created this Content + /// + [DataMember] + public int UserId + { + get { return _userId; } + set + { + _userId = value; + OnPropertyChanged(UserIdSelector); + } + } + + /// + /// Boolean indicating whether this ContentType is Trashed or not. + /// If ContentType is Trashed it will be located in the Recyclebin. + /// + [DataMember] + public bool Trashed //NOTE Is this relevant for a ContentType? + { + get { return _trashed; } + set + { + _trashed = value; + OnPropertyChanged(TrashedSelector); + } + } + + /// + /// Gets or sets a list of integer Ids for allowed ContentTypes + /// + [DataMember] + public IEnumerable AllowedContentTypes + { + get { return _allowedContentTypes; } + set + { + _allowedContentTypes = value; + OnPropertyChanged(AllowedContentTypesSelector); + } + } + + /// + /// List of PropertyGroups available on this ContentType + /// + /// A PropertyGroup corresponds to a Tab in the UI + [DataMember] + public PropertyGroupCollection PropertyGroups + { + get { return _propertyGroups; } + set + { + _propertyGroups = value; + _propertyGroups.CollectionChanged += PropertyGroupsChanged; + } + } + + /// + /// List of PropertyTypes available on this ContentType. + /// This list aggregates PropertyTypes across the PropertyGroups. + /// + [IgnoreDataMember] + public IEnumerable PropertyTypes + { + get { return PropertyGroups.SelectMany(x => x.PropertyTypes); } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/IContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IContentRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/IContentTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentTypeRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IContentTypeRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IContentTypeRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/IDataTypeDefinitionRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IDataTypeDefinitionRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IDataTypeDefinitionRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IDataTypeDefinitionRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/IDictionaryRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IDictionaryRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IDictionaryRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IDictionaryRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/ILanguageRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/ILanguageRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/ILanguageRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/ILanguageRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/IMacroRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMacroRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IMacroRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IMacroRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaRepository.cs new file mode 100644 index 0000000000..354a8a7b1e --- /dev/null +++ b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaRepository.cs @@ -0,0 +1,9 @@ +using Umbraco.Core.Models; + +namespace Umbraco.Core.Persistence.Repositories +{ + public interface IMediaRepository : IRepositoryQueryable + { + + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaTypeRepository.cs new file mode 100644 index 0000000000..e92cb3fecf --- /dev/null +++ b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IMediaTypeRepository.cs @@ -0,0 +1,9 @@ +using Umbraco.Core.Models; + +namespace Umbraco.Core.Persistence.Repositories +{ + public interface IMediaTypeRepository : IRepositoryQueryable + { + + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Persistence/Repositories/IRelationRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IRelationRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IRelationRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IRelationRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/IRelationTypeRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IRelationTypeRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IRelationTypeRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IRelationTypeRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/IRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/IRepositoryQueryable.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IRepositoryQueryable.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IRepositoryQueryable.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IRepositoryQueryable.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/IScriptRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IScriptRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IScriptRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IScriptRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/IStylesheetRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/IStylesheetRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/IStylesheetRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/IStylesheetRepository.cs diff --git a/src/Umbraco.Core/Persistence/Repositories/ITemplateRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Interfaces/ITemplateRepository.cs similarity index 100% rename from src/Umbraco.Core/Persistence/Repositories/ITemplateRepository.cs rename to src/Umbraco.Core/Persistence/Repositories/Interfaces/ITemplateRepository.cs diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 47b1becb9f..089b9c51f6 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -90,6 +90,7 @@ + @@ -122,20 +123,22 @@ - - - - - - - - - + + + + + + + + + + + - - - - + + + +