﻿using System;

namespace Communist.Security
{
    /// <summary>
    /// Represents a template to statically define a security role
    /// </summary>
    [AttributeUsage(AttributeTargets.Field)]
    public sealed class RoleAttribute : Attribute
    {
        /// <summary>
        /// Creates a new instance or <see cref="RoleAttribute"/>
        /// </summary>
        /// <param name="key">A key value to uniquely identify the role</param>
        /// <param name="name">The name of the role</param>
        public RoleAttribute(string key, string name)
        {
            Key = key;
            Name = name;
            IsUserRole = true;
        }

        /// <summary>
        /// Gets the key
        /// </summary>
        public string Key { get; }

        /// <summary>
        /// Gets the name
        /// </summary>
        public string Name { get; }

        /// <summary>
        /// Gets or sets the context
        /// </summary>
        public string Context { get; set; }

        /// <summary>
        /// Gets or sets the description
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets a value indicating if the role is hidden
        /// </summary>
        public bool IsHidden { get; set; }

        /// <summary>
        /// Gets or sets a value indicating if the role is a user role
        /// </summary>
        public bool IsUserRole { get; set; }

        /// <summary>
        /// Gets or sets the permissions
        /// </summary>
        public string[] Permissions { get; set; }

        /// <summary>
        /// Gets or set the tags
        /// </summary>
        public string[] Tags { get; set; }
    }
}
