using ExtensiblePortfolioSite.SDK.Git;

using System;

namespace ExtensiblePortfolioSite.SDK.Caching
{
    /// <summary>
    /// Represents a Cache Item Provider
    /// </summary>
    /// <typeparam name="TCacheItemType">Cache Item Base Type</typeparam>
    public interface ICacheProvider<TCacheItemType> where TCacheItemType : ICacheItem
    {
        /// <summary>
        /// Registers a Cache Item
        /// </summary>
        /// <param name="Item"></param>
        void Register(TCacheItemType Item);

        /// <summary>
        /// Unregisters a Cache Item
        /// </summary>
        /// <param name="Item"></param>
        void Unregister(TCacheItemType Item);
    }

    /// <summary>
    /// Represents a Cache Item
    /// </summary>
    public interface ICacheItem
    {
        /// <summary>
        /// Invalidates the Cache Item
        /// </summary>
        void Invalidate();
    }

    /// <summary>
    /// Represents a Cache Item of Type <typeparamref name="T"/>
    /// </summary>
    /// <typeparam name="T">Cache Item Type</typeparam>
    public interface ICacheItem<T> : ICacheItem
    {
        /// <summary>
        /// Gets the Requested Cache Item
        /// </summary>
        /// <returns></returns>
        T GetValue();
    }

    /// <summary>
    /// Git Cache Invalidate or Changed Delegate Callback
    /// </summary>
    public delegate void GitCacheInvalidateDelegate();

    /// <summary>
    /// A Git Cache Provider
    /// </summary>
    public interface IGitCacheProvider : ICacheProvider<GitCacheItemBase>
    {
        /// <summary>
        /// The Service Provider tied to this Cache
        /// </summary>
        public GitService ServiceProvider { get; }

        /// <summary>
        /// Get a User by its URL
        /// </summary>
        /// <param name="UserProfile">User Profile URL</param>
        /// <returns></returns>
        public GitCacheItemBase<IUser> GetUser(Uri UserProfile);
        /// <summary>
        /// Get a Repositroy by its URL
        /// </summary>
        /// <param name="RepositoryURL">Repository URL</param>
        /// <returns></returns>
        public GitCacheItemBase<IRepository> GetRepository(Uri RepositoryURL);
    }

}
