Rock.Web.Fingerprint.Tag C# (CSharp) Method

Tag() public static method

Tags the specified root relative path.
public static Tag ( string rootRelativePath ) : string
rootRelativePath string The root relative path.
return string
        public static string Tag( string rootRelativePath )
        {
            if ( HttpRuntime.Cache[rootRelativePath] == null )
            {
                string absolute = HostingEnvironment.MapPath( rootRelativePath );
                if ( File.Exists( absolute ) )
                {
                    DateTime date = File.GetLastWriteTime( absolute );

                    string result = rootRelativePath + "?v=" + date.Ticks;
                    HttpRuntime.Cache.Insert( rootRelativePath, result, new CacheDependency( absolute ) );
                }
            }

            return HttpRuntime.Cache[rootRelativePath] as string;
        }

Usage Example

        /// <summary>
        /// Gets the eval data.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="target">The target.</param>
        /// <param name="entry">The entry.</param>
        /// <returns></returns>
        public static object GetEvalData(string expression, Type target, string entry)
        {
            string result = Fingerprint.Tag(System.Web.VirtualPathUtility.ToAbsolute(expression));

            return(result);
        }
Fingerprint