2018-11-02 14:55:34 +11:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.Models
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2018-11-08 16:33:19 +01:00
|
|
|
|
/// Represents a scheduled action for a document.
|
2018-11-02 14:55:34 +11:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
|
[DataContract(IsReference = true)]
|
2018-11-05 17:20:26 +11:00
|
|
|
|
public class ContentSchedule : IDeepCloneable
|
2018-11-02 14:55:34 +11:00
|
|
|
|
{
|
2018-11-08 16:33:19 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="ContentSchedule"/> class.
|
|
|
|
|
|
/// </summary>
|
2018-11-02 14:55:34 +11:00
|
|
|
|
public ContentSchedule(int id, string culture, DateTime date, ContentScheduleChange change)
|
|
|
|
|
|
{
|
|
|
|
|
|
Id = id;
|
|
|
|
|
|
Culture = culture;
|
|
|
|
|
|
Date = date;
|
|
|
|
|
|
Change = change;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-11-08 16:33:19 +01:00
|
|
|
|
/// Gets the unique identifier of the document targeted by the scheduled action.
|
2018-11-02 14:55:34 +11:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[DataMember]
|
|
|
|
|
|
public int Id { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-11-08 16:33:19 +01:00
|
|
|
|
/// Gets the culture of the scheduled action.
|
2018-11-02 14:55:34 +11:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
2018-11-08 16:33:19 +01:00
|
|
|
|
/// string.Empty represents the invariant culture.
|
2018-11-02 14:55:34 +11:00
|
|
|
|
/// </remarks>
|
|
|
|
|
|
[DataMember]
|
|
|
|
|
|
public string Culture { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-11-08 16:33:19 +01:00
|
|
|
|
/// Gets the date of the scheduled action.
|
2018-11-02 14:55:34 +11:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[DataMember]
|
|
|
|
|
|
public DateTime Date { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-11-08 16:33:19 +01:00
|
|
|
|
/// Gets the action to take.
|
2018-11-02 14:55:34 +11:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[DataMember]
|
|
|
|
|
|
public ContentScheduleChange Change { get; }
|
2018-11-05 17:20:26 +11:00
|
|
|
|
|
2018-11-08 16:33:19 +01:00
|
|
|
|
// fixme/review - must implement Equals?
|
|
|
|
|
|
// fixing ContentScheduleCollection.Equals which was broken, breaks content Can_Deep_Clone test
|
|
|
|
|
|
// because SequenceEqual on the inner sorted lists fails, because it ends up doing reference-equal
|
|
|
|
|
|
// on each content schedule - so we *have* to implement Equals for us too?
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
|
=> obj is ContentSchedule other && Equals(other);
|
|
|
|
|
|
|
|
|
|
|
|
public bool Equals(ContentSchedule other)
|
|
|
|
|
|
{
|
|
|
|
|
|
// don't compare Ids, two ContentSchedule are equal if they are for the same change
|
|
|
|
|
|
// for the same culture, on the same date - and the collection deals w/duplicates
|
|
|
|
|
|
return Culture.InvariantEquals(other.Culture) && Date == other.Date && Change == other.Change;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-05 17:20:26 +11:00
|
|
|
|
public object DeepClone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new ContentSchedule(Id, Culture, Date, Change);
|
|
|
|
|
|
}
|
2018-11-02 14:55:34 +11:00
|
|
|
|
}
|
|
|
|
|
|
}
|