* Rename Umbraco.Core namespace to Umbraco.Cms.Core * Move extension methods in core project to Umbraco.Extensions * Move extension methods in core project to Umbraco.Extensions * Rename Umbraco.Examine namespace to Umbraco.Cms.Examine * Move examine extensions to Umbraco.Extensions namespace * Reflect changed namespaces in Builder and fix unit tests * Adjust namespace in Umbraco.ModelsBuilder.Embedded * Adjust namespace in Umbraco.Persistence.SqlCe * Adjust namespace in Umbraco.PublishedCache.NuCache * Align namespaces in Umbraco.Web.BackOffice * Align namespaces in Umbraco.Web.Common * Ensure that SqlCeSupport is still enabled after changing the namespace * Align namespaces in Umbraco.Web.Website * Align namespaces in Umbraco.Web.UI.NetCore * Align namespaces in Umbraco.Tests.Common * Align namespaces in Umbraco.Tests.UnitTests * Align namespaces in Umbraco.Tests.Integration * Fix errors caused by changed namespaces * Fix integration tests * Undo the Umbraco.Examine.Lucene namespace change This breaks integration tests on linux, since the namespace wont exists there because it's only used on windows. * Fix merge * Fix Merge
85 lines
3.6 KiB
C#
85 lines
3.6 KiB
C#
using System;
|
|
using System.Runtime.Serialization;
|
|
|
|
namespace Umbraco.Cms.Core.Models
|
|
{
|
|
/// <summary>
|
|
/// Represents a Media object
|
|
/// </summary>
|
|
[Serializable]
|
|
[DataContract(IsReference = true)]
|
|
public class Media : ContentBase, IMedia
|
|
{
|
|
/// <summary>
|
|
/// Constructor for creating a Media object
|
|
/// </summary>
|
|
/// <param name="name">name of the Media object</param>
|
|
/// <param name="parent">Parent <see cref="IMedia"/> object</param>
|
|
/// <param name="contentType">MediaType for the current Media object</param>
|
|
public Media(string name, IMedia parent, IMediaType contentType)
|
|
: this(name, parent, contentType, new PropertyCollection())
|
|
{ }
|
|
|
|
/// <summary>
|
|
/// Constructor for creating a Media object
|
|
/// </summary>
|
|
/// <param name="name">name of the Media object</param>
|
|
/// <param name="parent">Parent <see cref="IMedia"/> object</param>
|
|
/// <param name="contentType">MediaType for the current Media object</param>
|
|
/// <param name="properties">Collection of properties</param>
|
|
public Media(string name, IMedia parent, IMediaType contentType, IPropertyCollection properties)
|
|
: base(name, parent, contentType, properties)
|
|
{ }
|
|
|
|
/// <summary>
|
|
/// Constructor for creating a Media object
|
|
/// </summary>
|
|
/// <param name="name">name of the Media object</param>
|
|
/// <param name="parentId">Id of the Parent IMedia</param>
|
|
/// <param name="contentType">MediaType for the current Media object</param>
|
|
public Media(string name, int parentId, IMediaType contentType)
|
|
: this(name, parentId, contentType, new PropertyCollection())
|
|
{ }
|
|
|
|
/// <summary>
|
|
/// Constructor for creating a Media object
|
|
/// </summary>
|
|
/// <param name="name">Name of the Media object</param>
|
|
/// <param name="parentId">Id of the Parent IMedia</param>
|
|
/// <param name="contentType">MediaType for the current Media object</param>
|
|
/// <param name="properties">Collection of properties</param>
|
|
public Media(string name, int parentId, IMediaType contentType, IPropertyCollection properties)
|
|
: base(name, parentId, contentType, properties)
|
|
{ }
|
|
|
|
/// <summary>
|
|
/// Changes the <see cref="IMediaType"/> for the current Media object
|
|
/// </summary>
|
|
/// <param name="contentType">New MediaType for this Media</param>
|
|
/// <remarks>Leaves PropertyTypes intact after change</remarks>
|
|
internal void ChangeContentType(IMediaType contentType)
|
|
{
|
|
ChangeContentType(contentType, false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Changes the <see cref="IMediaType"/> for the current Media object and removes PropertyTypes,
|
|
/// which are not part of the new MediaType.
|
|
/// </summary>
|
|
/// <param name="contentType">New MediaType for this Media</param>
|
|
/// <param name="clearProperties">Boolean indicating whether to clear PropertyTypes upon change</param>
|
|
internal void ChangeContentType(IMediaType contentType, bool clearProperties)
|
|
{
|
|
ChangeContentType(new SimpleContentType(contentType));
|
|
|
|
if (clearProperties)
|
|
Properties.EnsureCleanPropertyTypes(contentType.CompositionPropertyTypes);
|
|
else
|
|
Properties.EnsurePropertyTypes(contentType.CompositionPropertyTypes);
|
|
|
|
Properties.ClearCollectionChangedEvents(); // be sure not to double add
|
|
Properties.CollectionChanged += PropertiesChanged;
|
|
}
|
|
}
|
|
}
|