using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace ExtensiblePortfolioSite.SDK.Plugins
{
    /// <summary>
    /// Internal Marker Attribute
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public abstract class EPSMarkerAttribute : Attribute { }


    /// <summary>
    /// Describes the ExtensiblePortfolioSite Plugin
    /// </summary>
    [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
    public class EPSPluginAttribute : Attribute
    {
        /// <summary>
        /// Plugin Name
        /// </summary>
        public String Name;

        /// <summary>
        /// Plugin Version
        /// </summary>
        public PluginVersion Version;

        /// <summary>
        /// Weather or not this Plugin Supports Runtime Upgrades
        /// </summary>
        public Boolean SupportsRuntimeUpgrades;

        /// <summary>
        /// Plugin Auther
        /// </summary>
        public String? Auther;

        /// <summary>
        /// Plugin Website
        /// </summary>
        public String? Website;

        /// <inheritdoc cref="EPSPluginAttribute"/>
        /// <param name="Name">Plugin Name</param>
        /// <param name="Major">Plugin Version, Major Number</param>
        /// <param name="Minor">Plugin Version, Major Number</param>
        /// <param name="Build">Plugin Version, Build Number</param>
        /// <param name="Revision">Plugin Version, Revision Number</param>
        /// <param name="SupportsRuntimeUpgrades">Supports Runtime Upgrading of the Plugin</param>
        /// <param name="Auther">Plugin Auther</param>
        /// <param name="Website">Plugin Website/Repository</param>
        public EPSPluginAttribute(
            String Name,
            Boolean SupportsRuntimeUpgrades,
            UInt32 Major,
            UInt32 Minor,
            UInt32 Build = 0u,
            UInt32 Revision = 0u,
            String? Auther = null,
            String? Website = null
            )
        {
            this.Name = Name;
            this.Version = new PluginVersion(Major, Minor, Build, Revision);
            this.SupportsRuntimeUpgrades = SupportsRuntimeUpgrades;
            this.Auther = Auther;
            this.Website = Website;
        }
    }

    /// <summary>
    /// Defineds a Resource Container
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    public sealed class ResourceContainerAttribute : EPSMarkerAttribute
    {
        /// <summary>
        /// Supported Schemas
        /// </summary>
        public String[] Schemes { get; }

        /// <inheritdoc cref="ResourceContainerAttribute"/>
        /// <param name="Schemes">Supported Schemas</param>
        public ResourceContainerAttribute(params String[] Schemes) => this.Schemes = Schemes;

    }

    /// <summary>
    /// Git Providers marked withi this attribute will be auto-imported at startup!
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    public sealed class GitProviderAttribute : EPSMarkerAttribute
    {
        /// <summary>
        /// The Service which this GitProvider is for
        /// </summary>
        public String ServiceName { get; }

        /// <inheritdoc cref="GitProviderAttribute"/>
        /// <param name="ServiceName">The Service which this GitProvider is for</param>
        public GitProviderAttribute(String ServiceName) => this.ServiceName = ServiceName;
    }
}
