using System; using System.Runtime.Serialization; using System.Collections.Generic; using System.Linq; using GitHub.Services.WebApi; namespace GitHub.DistributedTask.WebApi { [DataContract] public class TaskGroup: TaskDefinition { /// /// A task group lets you to encapsulate a sequence of tasks already defined in a build definition, a release definition or a task group into a single reusable task. /// public TaskGroup() { this.DefinitionType = TaskDefinitionType.MetaTask; } private TaskGroup(TaskGroup definition) : base(definition) { this.DefinitionType = TaskDefinitionType.MetaTask; this.Owner = definition.Owner; this.Revision = definition.Revision; this.CreatedOn = definition.CreatedOn; this.ModifiedOn = definition.ModifiedOn; this.Comment = definition.Comment; this.ParentDefinitionId = definition.ParentDefinitionId; if (definition.Tasks != null) { this.Tasks = new List(definition.Tasks.Select(x => x.Clone())); } if (definition.CreatedBy != null) { this.CreatedBy = definition.CreatedBy.Clone(); } if (definition.ModifiedBy != null) { this.ModifiedBy = definition.ModifiedBy.Clone(); } } public IList Tasks { get { if (m_tasks == null) { m_tasks = new List(); } return m_tasks; } set { if (value == null) { m_tasks = new List(); } else { this.m_tasks = value; } } } /// /// Gets or sets the owner. /// [DataMember(EmitDefaultValue = false)] public String Owner { get; set; } /// /// Gets or sets revision. /// [DataMember] public Int32 Revision { get; set; } /// /// Gets or sets the identity who created. /// [DataMember] public IdentityRef CreatedBy { get; set; } /// /// Gets or sets date on which it got created. /// [DataMember] public DateTime CreatedOn { get; set; } /// /// Gets or sets the identity who modified. /// [DataMember] public IdentityRef ModifiedBy { get; set; } /// /// Gets or sets date on which it got modified. /// [DataMember] public DateTime ModifiedOn { get; set; } /// /// Gets or sets comment. /// [DataMember(EmitDefaultValue = false)] public String Comment { get; set; } /// /// Gets or sets parent task group Id. This is used while creating a draft task group. /// [DataMember(EmitDefaultValue = false)] public Guid? ParentDefinitionId { get; set; } /// /// Gets or sets as 'true' to indicate as deleted, 'false' otherwise. /// [DataMember(EmitDefaultValue = false)] public bool Deleted { get; set; } internal new TaskGroup Clone() { return new TaskGroup(this); } /// /// Gets or sets the tasks. /// [DataMember(Name = "Tasks")] private IList m_tasks; } }