// Kyoo - A portable and vast media library solution. // Copyright (c) Kyoo. // // See AUTHORS.md and LICENSE file in the project root for full license information. // // Kyoo is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // // Kyoo is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Kyoo. If not, see . 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)]; } } }