Moving public interfaces for a cleaner structure in the .Core project.

This commit is contained in:
Morten@Thinkpad-X220
2012-10-09 09:49:55 -02:00
parent b8c0969a85
commit 62c69edf02
19 changed files with 300 additions and 14 deletions

View File

@@ -9,7 +9,7 @@ using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
{
/// <summary>
/// Represents the type of a <see cref="Content"/> object
/// Represents the contnet type that a <see cref="Content"/> object is based on
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
@@ -247,6 +247,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// Gets or sets a list of integer Ids for allowed ContentTypes
/// </summary>
[DataMember]
public IEnumerable<int> AllowedContentTypes
{
get { return _allowedContentTypes; }
@@ -285,6 +286,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// List of ContentTypes that make up a composition of PropertyGroups and PropertyTypes for the current ContentType
/// </summary>
[DataMember]
public List<IContentTypeComposition> ContentTypeComposition
{
get { return _contentTypeComposition; }

View File

@@ -70,6 +70,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// Gets or Sets the Id of the Parent for the Media
/// </summary>
[DataMember]
public int ParentId
{
get { return _parentId; }
@@ -83,6 +84,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// Gets or Sets the Name of the Media
/// </summary>
[DataMember]
public string Name
{
get { return _name; }
@@ -96,6 +98,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// Gets the Url name of the Media item
/// </summary>
[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
/// <summary>
/// Gets or Sets the Sort Order of the Media
/// </summary>
[DataMember]
public int SortOrder
{
get { return _sortOrder; }
@@ -122,6 +126,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// Gets or Sets the Level of the Media
/// </summary>
[DataMember]
public int Level
{
get { return _level; }
@@ -135,6 +140,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// Gets or Sets the Path of the Media
/// </summary>
[DataMember]
public string Path
{
get { return _path; }
@@ -148,6 +154,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// Id of the user who created the Media
/// </summary>
[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.
/// </summary>
[DataMember]
public bool Trashed
{
get { return _trashed; }
@@ -175,6 +183,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// Integer Id of the default MediaType
/// </summary>
[DataMember]
public int ContentTypeId
{
get { return _contentTypeId; }
@@ -188,6 +197,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// List of properties, which make up all the data available for this Media object
/// </summary>
[DataMember]
public PropertyCollection Properties
{
get { return _properties; }
@@ -201,6 +211,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// List of PropertyGroups available on this Media object
/// </summary>
[IgnoreDataMember]
public IEnumerable<PropertyGroup> PropertyGroups
{
get { return _contentType.PropertyGroups; }
@@ -209,6 +220,7 @@ namespace Umbraco.Core.Models
/// <summary>
/// List of PropertyTypes available on this Media object
/// </summary>
[IgnoreDataMember]
public IEnumerable<PropertyType> PropertyTypes
{
get { return _contentType.PropertyTypes; }

View File

@@ -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
{
/// <summary>
/// Represents the content type that a <see cref="Media"/> object is based on
/// </summary>
[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<int> _allowedContentTypes;
public MediaType()
{
_allowedContentTypes = new List<int>();
_propertyGroups = new PropertyGroupCollection();
}
private static readonly PropertyInfo NameSelector = ExpressionHelper.GetPropertyInfo<MediaType, string>(x => x.Name);
private static readonly PropertyInfo ParentIdSelector = ExpressionHelper.GetPropertyInfo<MediaType, int>(x => x.ParentId);
private static readonly PropertyInfo SortOrderSelector = ExpressionHelper.GetPropertyInfo<MediaType, int>(x => x.SortOrder);
private static readonly PropertyInfo LevelSelector = ExpressionHelper.GetPropertyInfo<MediaType, int>(x => x.Level);
private static readonly PropertyInfo PathSelector = ExpressionHelper.GetPropertyInfo<MediaType, string>(x => x.Path);
private static readonly PropertyInfo AliasSelector = ExpressionHelper.GetPropertyInfo<MediaType, string>(x => x.Alias);
private static readonly PropertyInfo DescriptionSelector = ExpressionHelper.GetPropertyInfo<MediaType, string>(x => x.Description);
private static readonly PropertyInfo IconSelector = ExpressionHelper.GetPropertyInfo<MediaType, string>(x => x.Icon);
private static readonly PropertyInfo ThumbnailSelector = ExpressionHelper.GetPropertyInfo<MediaType, string>(x => x.Thumbnail);
private static readonly PropertyInfo UserIdSelector = ExpressionHelper.GetPropertyInfo<MediaType, int>(x => x.UserId);
private static readonly PropertyInfo TrashedSelector = ExpressionHelper.GetPropertyInfo<MediaType, bool>(x => x.Trashed);
private static readonly PropertyInfo AllowedContentTypesSelector = ExpressionHelper.GetPropertyInfo<MediaType, IEnumerable<int>>(x => x.AllowedContentTypes);
private readonly static PropertyInfo PropertyGroupCollectionSelector = ExpressionHelper.GetPropertyInfo<MediaType, PropertyGroupCollection>(x => x.PropertyGroups);
void PropertyGroupsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
OnPropertyChanged(PropertyGroupCollectionSelector);
}
/// <summary>
/// Gets or sets the Id of the Parent entity
/// </summary>
/// <remarks>Might not be necessary if handled as a relation?</remarks>
[DataMember]
public int ParentId
{
get { return _parentId; }
set
{
_parentId = value;
OnPropertyChanged(ParentIdSelector);
}
}
/// <summary>
/// Gets or sets the name of the current entity
/// </summary>
[DataMember]
public string Name
{
get { return _name; }
set
{
_name = value;
OnPropertyChanged(NameSelector);
}
}
/// <summary>
/// Gets or sets the level of the content entity
/// </summary>
[DataMember]
public int Level //NOTE Is this relevant for a ContentType?
{
get { return _level; }
set
{
_level = value;
OnPropertyChanged(LevelSelector);
}
}
/// <summary>
/// Gets of sets the path
/// </summary>
[DataMember]
public string Path //NOTE Is this relevant for a ContentType?
{
get { return _path; }
set
{
_path = value;
OnPropertyChanged(PathSelector);
}
}
/// <summary>
/// The Alias of the ContentType
/// </summary>
[DataMember]
public string Alias
{
get { return _alias; }
set
{
_alias = value;
OnPropertyChanged(AliasSelector);
}
}
/// <summary>
/// Description for the ContentType
/// </summary>
[DataMember]
public string Description
{
get { return _description; }
set
{
_description = value;
OnPropertyChanged(DescriptionSelector);
}
}
/// <summary>
/// Gets or sets the sort order of the content entity
/// </summary>
[DataMember]
public int SortOrder
{
get { return _sortOrder; }
set
{
_sortOrder = value;
OnPropertyChanged(SortOrderSelector);
}
}
/// <summary>
/// Name of the icon (sprite class) used to identify the ContentType
/// </summary>
[DataMember]
public string Icon
{
get { return _icon; }
set
{
_icon = value;
OnPropertyChanged(IconSelector);
}
}
/// <summary>
/// Name of the thumbnail used to identify the ContentType
/// </summary>
[DataMember]
public string Thumbnail
{
get { return _thumbnail; }
set
{
_thumbnail = value;
OnPropertyChanged(ThumbnailSelector);
}
}
/// <summary>
/// Id of the user who created this Content
/// </summary>
[DataMember]
public int UserId
{
get { return _userId; }
set
{
_userId = value;
OnPropertyChanged(UserIdSelector);
}
}
/// <summary>
/// Boolean indicating whether this ContentType is Trashed or not.
/// If ContentType is Trashed it will be located in the Recyclebin.
/// </summary>
[DataMember]
public bool Trashed //NOTE Is this relevant for a ContentType?
{
get { return _trashed; }
set
{
_trashed = value;
OnPropertyChanged(TrashedSelector);
}
}
/// <summary>
/// Gets or sets a list of integer Ids for allowed ContentTypes
/// </summary>
[DataMember]
public IEnumerable<int> AllowedContentTypes
{
get { return _allowedContentTypes; }
set
{
_allowedContentTypes = value;
OnPropertyChanged(AllowedContentTypesSelector);
}
}
/// <summary>
/// List of PropertyGroups available on this ContentType
/// </summary>
/// <remarks>A PropertyGroup corresponds to a Tab in the UI</remarks>
[DataMember]
public PropertyGroupCollection PropertyGroups
{
get { return _propertyGroups; }
set
{
_propertyGroups = value;
_propertyGroups.CollectionChanged += PropertyGroupsChanged;
}
}
/// <summary>
/// List of PropertyTypes available on this ContentType.
/// This list aggregates PropertyTypes across the PropertyGroups.
/// </summary>
[IgnoreDataMember]
public IEnumerable<PropertyType> PropertyTypes
{
get { return PropertyGroups.SelectMany(x => x.PropertyTypes); }
}
}
}

View File

@@ -0,0 +1,9 @@
using Umbraco.Core.Models;
namespace Umbraco.Core.Persistence.Repositories
{
public interface IMediaRepository : IRepositoryQueryable<int, IMedia>
{
}
}

View File

@@ -0,0 +1,9 @@
using Umbraco.Core.Models;
namespace Umbraco.Core.Persistence.Repositories
{
public interface IMediaTypeRepository : IRepositoryQueryable<int, IMediaType>
{
}
}

View File

@@ -90,6 +90,7 @@
<Compile Include="Models\IFile.cs" />
<Compile Include="Models\Language.cs" />
<Compile Include="Models\Media.cs" />
<Compile Include="Models\MediaType.cs" />
<Compile Include="Models\Relation.cs" />
<Compile Include="Models\RelationType.cs" />
<Compile Include="Models\Script.cs" />
@@ -122,20 +123,22 @@
<Compile Include="Persistence\Repositories\DataTypeDefinitionRepository.cs" />
<Compile Include="Persistence\Repositories\DictionaryRepository.cs" />
<Compile Include="Persistence\Repositories\FileRepository.cs" />
<Compile Include="Persistence\Repositories\IContentRepository.cs" />
<Compile Include="Persistence\Repositories\IContentTypeRepository.cs" />
<Compile Include="Persistence\Repositories\IDataTypeDefinitionRepository.cs" />
<Compile Include="Persistence\Repositories\IDictionaryRepository.cs" />
<Compile Include="Persistence\Repositories\ILanguageRepository.cs" />
<Compile Include="Persistence\Repositories\IMacroRepository.cs" />
<Compile Include="Persistence\Repositories\IRelationRepository.cs" />
<Compile Include="Persistence\Repositories\IRelationTypeRepository.cs" />
<Compile Include="Persistence\Repositories\IRepositoryQueryable.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IContentRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IContentTypeRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IDataTypeDefinitionRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IDictionaryRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\ILanguageRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IMacroRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IMediaRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IMediaTypeRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IRelationRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IRelationTypeRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IRepositoryQueryable.cs" />
<Compile Include="Persistence\Relators\TabPropertyTypeRelator.cs" />
<Compile Include="Persistence\Repositories\IScriptRepository.cs" />
<Compile Include="Persistence\Repositories\IRepository.cs" />
<Compile Include="Persistence\Repositories\IStylesheetRepository.cs" />
<Compile Include="Persistence\Repositories\ITemplateRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IScriptRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\IStylesheetRepository.cs" />
<Compile Include="Persistence\Repositories\Interfaces\ITemplateRepository.cs" />
<Compile Include="Persistence\Repositories\LanguageRepository.cs" />
<Compile Include="Persistence\Repositories\MacroRepository.cs" />
<Compile Include="Persistence\Repositories\PetaPocoRepositoryBase.cs" />