using System; using System.Reflection; using System.Runtime.Serialization; using Umbraco.Core.Models.Entities; namespace Umbraco.Core.Models { /// /// Represents a Task /// [Serializable] [DataContract(IsReference = true)] public class Task : EntityBase { private bool _closed; private TaskType _taskType; private int _entityId; private int _ownerUserId; private int _assigneeUserId; private string _comment; public Task(TaskType taskType) { _taskType = taskType; } private static readonly Lazy Ps = new Lazy(); private class PropertySelectors { public readonly PropertyInfo ClosedSelector = ExpressionHelper.GetPropertyInfo(x => x.Closed); public readonly PropertyInfo TaskTypeSelector = ExpressionHelper.GetPropertyInfo(x => x.TaskType); public readonly PropertyInfo EntityIdSelector = ExpressionHelper.GetPropertyInfo(x => x.EntityId); public readonly PropertyInfo OwnerUserIdSelector = ExpressionHelper.GetPropertyInfo(x => x.OwnerUserId); public readonly PropertyInfo AssigneeUserIdSelector = ExpressionHelper.GetPropertyInfo(x => x.AssigneeUserId); public readonly PropertyInfo CommentSelector = ExpressionHelper.GetPropertyInfo(x => x.Comment); } /// /// Gets or sets a boolean indicating whether the task is closed /// [DataMember] public bool Closed { get { return _closed; } set { SetPropertyValueAndDetectChanges(value, ref _closed, Ps.Value.ClosedSelector); } } /// /// Gets or sets the TaskType of the Task /// [DataMember] public TaskType TaskType { get { return _taskType; } set { SetPropertyValueAndDetectChanges(value, ref _taskType, Ps.Value.TaskTypeSelector); } } /// /// Gets or sets the Id of the entity, which this task is associated to /// [DataMember] public int EntityId { get { return _entityId; } set { SetPropertyValueAndDetectChanges(value, ref _entityId, Ps.Value.EntityIdSelector); } } /// /// Gets or sets the Id of the user, who owns this task /// [DataMember] public int OwnerUserId { get { return _ownerUserId; } set { SetPropertyValueAndDetectChanges(value, ref _ownerUserId, Ps.Value.OwnerUserIdSelector); } } /// /// Gets or sets the Id of the user, who is assigned to this task /// [DataMember] public int AssigneeUserId { get { return _assigneeUserId; } set { SetPropertyValueAndDetectChanges(value, ref _assigneeUserId, Ps.Value.AssigneeUserIdSelector); } } /// /// Gets or sets the Comment for the Task /// [DataMember] public string Comment { get { return _comment; } set { SetPropertyValueAndDetectChanges(value, ref _comment, Ps.Value.CommentSelector); } } } }