﻿namespace NCombinr
{
    public interface IPathResolver
    {
        /// <summary>
        /// Determines if the specified path to a resource is outside 
        /// of the allowed root path.
        /// </summary>
        /// <param name="fullResourcePath">
        /// A <see cref="string" /> containing the full file path to a resource.
        /// </param>
        /// <returns><c>true</c> if outside root path, <c>false</c> otherwise</returns>
        /// <example>
        /// Assuming the root path is "C:\inetpub\wwwroot\", 
        /// and <paramref name="fullResourcePath" /> is "C:\Windows\file.js",
        /// then <see cref="IsOutsideRootPath" /> will return <c>true</c>
        /// </example>
        bool IsOutsideRootPath(string fullResourcePath);

        /// <summary>
        /// Gets the full file system path to a file based on its virtual path.
        /// Any relative parts (i.e. /../) in the virtual path will be replaced by 
        /// their absolute value.
        /// </summary>
        /// <param name="virtualResourcePath">
        /// A <see cref="string" /> containing the full virtual path.</param>
        /// <returns>A <see cref="string" /> that contains the full file system path</returns>
        string GetFullResourcePath(string virtualResourcePath);

        /// <summary>
        /// Gets the full virtual path to a file resource by prepending the 
        /// resource root path.
        /// </summary>
        /// <param name="resourcePath">
        /// A <see cref="string"/> containing the path to a resource file without the root.
        /// </param>
        /// <returns>
        /// A <see cref="string "/> containing the full virtual path to 
        /// the specified resource path based starting from the root path.
        /// </returns>
        /// <example>
        /// Assuming the root path is "~/Content/",
        /// and <paramref name="resourcePath" /> is "js/file.js",
        /// then <see cref="GetVirtualPath" /> will return "~/Content/js/file.js"
        /// </example>
        string GetVirtualPath(string resourcePath);

        string GetFullRootPath();

        string VirtualToAbsolute(string virtualResourcePath, string applicationPath);
    }
}