using System; using System.Collections.Generic; using System.ComponentModel.Composition; using Kyoo.Abstractions.Controllers; namespace Kyoo.Abstractions.Models.Attributes { /// /// An attribute to inform how a works. /// [MetadataAttribute] [AttributeUsage(AttributeTargets.Class)] public class TaskMetadataAttribute : Attribute { /// /// The slug of the task, used to start it. /// public string Slug { get; } /// /// The name of the task that will be displayed to the user. /// public string Name { get; } /// /// A quick description of what this task will do. /// public string Description { get; } /// /// Should this task be automatically run at app startup? /// public bool RunOnStartup { get; set; } /// /// The priority of this task. Only used if is true. /// It allow one to specify witch task will be started first as tasked are run on a Priority's descending order. /// public int Priority { get; set; } /// /// true if this task should not be displayed to the user, false otherwise. /// public bool IsHidden { get; set; } /// /// Create a new with the given slug, name and description. /// /// The slug of the task, used to start it. /// The name of the task that will be displayed to the user. /// A quick description of what this task will do. public TaskMetadataAttribute(string slug, string name, string description) { Slug = slug; Name = name; Description = description; } /// /// Create a new using a dictionary of metadata. /// /// /// The dictionary of metadata. This method expect the dictionary to contain a field /// per property in this attribute, with the same types as the properties of this attribute. /// public TaskMetadataAttribute(IDictionary metadata) { Slug = (string)metadata[nameof(Slug)]; Name = (string)metadata[nameof(Name)]; Description = (string)metadata[nameof(Description)]; RunOnStartup = (bool)metadata[nameof(RunOnStartup)]; Priority = (int)metadata[nameof(Priority)]; IsHidden = (bool)metadata[nameof(IsHidden)]; } } }