using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Http;
using ZelWiki.Library.Interfaces;

namespace ZelWiki.Engine.Library.Interfaces
{
    public interface IZelEngineState
    {
        #region 参数

        public ISessionState? Session { get; }
        public IQueryCollection QueryString { get; }
        public IZelEngine Engine { get; }
        public IPage Page { get; }
        public int? Revision { get; }
        public HashSet<Constants.WikiMatchType> OmitMatches { get; }
        public int NestDepth { get; }

        #endregion

        #region 状态

        public string? PageTitle { get; set; }

        public Dictionary<string, string> Variables { get; }
        public Dictionary<string, string> Snippets { get; }
        public List<string> Tags { get; set; }
        public List<string> ProcessingInstructions { get; }
        public List<PageReference> OutgoingLinks { get; }
        public List<TableOfContentsTag> TableOfContents { get; }
        public List<string> Headers { get; }

        #endregion

        #region 结果

        public string HtmlResult { get; }
        public TimeSpan ProcessingTime { get; }
        public int ErrorCount { get; }
        public int MatchCount { get; }

        #endregion

        /// <summary>
        /// 
        /// </summary>
        public void SetStateValue<T>(string key, T value);

        /// <summary>
        /// 
        /// </summary>
        public bool TryGetStateValue<T>(string key, [MaybeNullWhen(false)] out T? outValue);

        /// <summary>
        /// 
        /// </summary>
        public T GetStateValue<T>(string key, T defaultValue);

        string GetNextQueryToken();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="page"></param>
        /// <param name="revision"></param>
        /// <returns></returns>
        IZelEngineState TransformChild(IPage page, int? revision = null);
    }
}