Esempio n. 1
0
    protected override async Task <IInputStream> GetContent(Uri uri)
    {
        var invalid = "Invalid Path";

        if (uri is null)
        {
            throw new Exception(invalid);
        }
        try
        {
            //Security!
            if (PathReader.IsMatch(uri.LocalPath))
            {
                var pathTail = PathReader.Replace(uri.LocalPath, "");
                pathTail = string.IsNullOrWhiteSpace(pathTail) ? "index.html" : pathTail;
                var f = await StorageFile.GetFileFromApplicationUriAsync(new Uri(Path.Combine(PathReaderLocal, pathTail)));

                return(await f.OpenAsync(FileAccessMode.Read));
            }
            if (uri.LocalPath.ToLowerInvariant() == PathEpub)
            {
                if (File is null)
                {
                    throw new Exception(invalid);
                }
                return(await File.OpenReadAsync());
            }
            throw new Exception(invalid);
        }
        catch (Exception) { throw; }
    }