using System.Runtime.Serialization; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Models; /// /// Represents a scheduled action for a document. /// [Serializable] [DataContract(IsReference = true)] public class ContentSchedule : IDeepCloneable { /// /// Initializes a new instance of the class. /// public ContentSchedule(string culture, DateTime date, ContentScheduleAction action) { Id = Guid.Empty; // will be assigned by document repository Culture = culture; Date = date; Action = action; } /// /// Initializes a new instance of the class. /// public ContentSchedule(Guid id, string culture, DateTime date, ContentScheduleAction action) { Id = id; Culture = culture; Date = date; Action = action; } /// /// Gets the unique identifier of the document targeted by the scheduled action. /// [DataMember] public Guid Id { get; set; } /// /// Gets the culture of the scheduled action. /// /// /// string.Empty represents the invariant culture. /// [DataMember] public string Culture { get; } /// /// Gets the date of the scheduled action. /// [DataMember] public DateTime Date { get; } /// /// Gets the action to take. /// [DataMember] public ContentScheduleAction Action { get; } public object DeepClone() => new ContentSchedule(Id, Culture, Date, Action); 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 Culture.InvariantEquals(other.Culture) && Date == other.Date && Action == other.Action; public override int GetHashCode() => throw new NotImplementedException(); }