예제 #1
0
        private string GetAssetFilePath(string cssFilePath, string url)
        {
            var queryStringPosition = url.IndexOf('?');

            if (queryStringPosition > -1)
            {
                url = url.Substring(0, queryStringPosition);
            }

            var resolvedUrl = string.Empty;

            var urlUri = new Uri(url, UriKind.RelativeOrAbsolute);

            if (!urlUri.IsAbsoluteUri)
            {
                if (!url.StartsWith("/"))
                {
                    var resolvedPath = Path.GetDirectoryName(cssFilePath);
                    var outputUri    = new Uri(resolvedPath + "/", UriKind.Absolute);

                    var resolvedSourcePath = new Uri(outputUri, urlUri);
                    resolvedUrl = resolvedSourcePath.LocalPath;
                }
                else
                {
                    resolvedUrl = ResolveAppRelativePathToFileSystem(url);
                }

                return(FileResolver.TryResolve(resolvedUrl).ToList()[0]);
            }

            return(urlUri.LocalPath);
        }
        /// <summary>
        /// Loads in a .kpdl file using a resolver from outside the instance
        /// </summary>
        /// <param name="path"></param>
        /// <param name="resolver"></param>
        public void Load(string file, IFileResolver resolver)
        {
            string path;

            if (!resolver.TryResolve(file, out path))
            {
                throw new FileNotFoundException($"Unable to locate file {file}");
            }

            Load(path);
        }