private async Task <Chapter> LoadData(int index, string title) { int[] count = this.GetCounts(this.fontsize); OKrStorage storage = new OKrStorage(); Windows.ApplicationModel.Package package = Windows.ApplicationModel.Package.Current; Windows.Storage.StorageFolder installedLocation = package.InstalledLocation; this.chapter = this.book.Chapters[index]; var file = await StorageFile.GetFileFromPathAsync(Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, @"Assets\Data\book\" + this.chapter.FileName + ".txt")); var content = await FileIO.ReadTextAsync(file, Windows.Storage.Streams.UnicodeEncoding.Utf8); Chapter chapter = null; if (content != null) { chapter = TextParser.GetChapter(content, count); chapter.Title = title; chapter.ChapterNo = index; } return(chapter); }
private async Task InitFile() { StorageFile category = await StorageFile.GetFileFromPathAsync(Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, @"Assets\Data\book\category.txt")); OKrStorage storage = new OKrStorage(); StorageFolder folder = await storage.GetFolderIfExistsAsync(Windows.Storage.ApplicationData.Current.LocalFolder, "book"); if (folder == null) { folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("book"); } StorageFile categoryFile = null; try { categoryFile = await folder.GetFileAsync("category.txt"); } catch { } if (categoryFile == null) { await category.CopyAsync(folder); } }
public async static Task <Book> GetBook(string url) { Book result = new Book(); OKrStorage storage = new OKrStorage(); string content = await storage.ReadString(url); MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(content)); StreamReader reader = null; try { reader = new StreamReader(stream); string str2 = null; int index = 0; while ((str2 = reader.ReadLine()) != null) { string[] strArray = str2.Replace("&&", "&").Split(new char[] { '&' }); if (strArray.Length >= 3) { Chapter item = new Chapter(); item.Title = strArray[0]; item.FileName = strArray[1]; item.Size = int.Parse(strArray[2]); item.ChapterNo = index; result.Chapters.Add(item); } index++; } reader.Dispose(); } catch (NullReferenceException ex) { } return(result); }
public async static Task<Book> GetBook(string url) { Book result = new Book(); OKrStorage storage = new OKrStorage(); string content = await storage.ReadString(url); MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(content)); StreamReader reader = null; try { reader = new StreamReader(stream); string str2 = null; int index = 0; while ((str2 = reader.ReadLine()) != null) { string[] strArray = str2.Replace("&&", "&").Split(new char[] { '&' }); if (strArray.Length >= 3) { Chapter item = new Chapter(); item.Title = strArray[0]; item.FileName = strArray[1]; item.Size = int.Parse(strArray[2]); item.ChapterNo = index; result.Chapters.Add(item); } index++; } reader.Dispose(); } catch (NullReferenceException ex) { } return result; }
public OKrStateContextBase(OKrStorage <TData> storage, bool cached) { this.cached = cached; this.storage = storage; this.data = default(TData); }
private async Task<Chapter> LoadData(int index, string title) { int[] count = this.GetCounts(this.fontsize); OKrStorage storage = new OKrStorage(); Windows.ApplicationModel.Package package = Windows.ApplicationModel.Package.Current; Windows.Storage.StorageFolder installedLocation = package.InstalledLocation; this.chapter = this.book.Chapters[index]; var file = await StorageFile.GetFileFromPathAsync(Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, @"Assets\Data\book\" + this.chapter.FileName + ".txt")); var content = await FileIO.ReadTextAsync(file, Windows.Storage.Streams.UnicodeEncoding.Utf8); Chapter chapter = null; if (content != null) { chapter = TextParser.GetChapter(content, count); chapter.Title = title; chapter.ChapterNo = index; } return chapter; }
public OKrBookContextBase(OKrBookService service, OKrStorage <TData> data, bool cached) : base(data, cached) { this.service = service; }
public OKrBookContextBase(OKrStorage <TData> data, bool cached) : this(new OKrBookService(), data, cached) { }