private HtmlDom SetOriginalCopyrightAndLicense(string dataDivString) { // All of the tests using this method require that the book is locked down (that is, a derivative that // is expected to have original copyright and license information). var html = "<html><head><meta name='lockedDownAsShell' content='true'></meta></head><body>" + dataDivString + "</body></html>"; var dom = new HtmlDom(html); var bookData = new BookData(dom, _collectionSettings, null); BookCopyrightAndLicense.SetOriginalCopyrightAndLicense(dom, bookData, _collectionSettings); return(dom); }
public void RemoveDataDivVariableForOneLanguage_WasLastForm_WholeElementRemoved() { var htmlDom = new HtmlDom(); var data = new BookData(htmlDom, new CollectionSettings(), null); data.Set("1", "one", "en"); var roundTripData = new BookData(htmlDom, new CollectionSettings(), null); roundTripData.RemoveSingleForm("1", "en"); Assert.IsNull(roundTripData.GetVariableOrNull("1", "en")); }
public override bool acceptMessageData(BinaryReader messageDataReader, TreeView outputTreeView) { bool handled = true; PacketOpcode opcode = Util.readOpcode(messageDataReader); switch (opcode) { // TODO: Add all BOOK_*_RESPONSE_EVENT case PacketOpcode.Evt_Writing__BookData_ID: { BookData message = BookData.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_Writing__BookModifyPage_ID: { BookModifyPage message = BookModifyPage.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_Writing__BookAddPage_ID: { BookAddPage message = BookAddPage.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_Writing__BookDeletePage_ID: { BookDeletePage message = BookDeletePage.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_Writing__BookPageData_ID: { BookPageData message = BookPageData.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } // TODO: Evt_Writing__GetInscription_ID case PacketOpcode.Evt_Writing__SetInscription_ID: { SetInscription message = SetInscription.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } default: { handled = false; break; } } return(handled); }
public void UpdateVariablesAndDataDivThroughDOM_VariableIsNull_DataDivForItRemoved() { var htmlDom = new HtmlDom(); var data = new BookData(htmlDom, new CollectionSettings(), null); data.Set("1", "one", "en"); data.Set("1", null, "es"); data.UpdateVariablesAndDataDivThroughDOM(); AssertThatXmlIn.Dom(htmlDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("html/body/div/div[@lang='en']", 1); AssertThatXmlIn.Dom(htmlDom.RawDom).HasSpecifiedNumberOfMatchesForXpath("html/body/div/div[@lang='es']", 0); }
public void PrettyPrintLanguage_AdjustsLang1() { var htmlDom = new HtmlDom(); var settingsettings = new CollectionSettings() { Language1Iso639Code = "pdc", Language1Name = "German, Kludged" }; var data = new BookData(htmlDom, settingsettings, null); Assert.That(data.PrettyPrintLanguage("pdc"), Is.EqualTo("German, Kludged")); }
protected override void ProcessElement(BookData bookData, BookPageData page, XmlReader xmlReader) { if (page.TermXmlIds == null) { page.TermXmlIds = new List <string>(); } var refTermXmlId = xmlReader.GetAttribute("n"); page.TermXmlIds.Add(refTermXmlId); }
public async Task <IActionResult> Get() { await Task.Delay(150); return(Ok(BookData.GetAll().GroupBy(l => l.Category) .Select(g => new CategoryDto { Name = g.Key, Count = g.Select(l => l.Id).Distinct().Count() }).OrderBy(x => x.Name))); }
public Delphi(BookData dataSet, RecommendationType type) { this.type = type; bool useCache = false; // by default don't use cache SimilarityMatrixRepository smRepo = new SimilarityMatrixRepository(useCache); this.similarityMatrix = smRepo.load(type, dataSet); this.dataSet = dataSet; maxPredictedRating = new Dictionary <int, double>(dataSet.getUserCount() / 2); }
public ReadController(IBookView page, string bookId, IBookRepository bookRepository, int offset = 0) { _data = new BookData(bookId); _bookView = page; _offset = offset; _bookRepository = bookRepository; _bookModel = _bookRepository.Get(bookId); _images = _data.LoadImages().ToList(); _pageLoader = new PageCompositor(_bookModel, (int)(AppSettings.Default.FontSettings.FontSize), new Size(page.GetSize().Width - AppSettings.Default.Margin.Left - AppSettings.Default.Margin.Right, page.GetSize().Height - AppSettings.Default.Margin.Top - AppSettings.Default.Margin.Bottom), _images); BookId = bookId; }
public void AfterAnimation(ref BookData Data) { Data._currentPageLeftPage = Data._nextPageLeftPart; Data._currentPageRightPage = Data._nextPageRightPart; Data._nextPageLeftPart = Data.PreNextPageLeftPart; Data._nextPageRightPart = Data.PreNextPageRightPart; Data.PreNextPageLeftPart = null; Data.PreNextPageRightPart = null; }
public BookEnt GetBookById(int id) { var book = new BookEnt(); using (var data = new BookData()) { book = data.GetBookById(id); } return(book); }
public async Task <IActionResult> SaveBook([FromBody] BookData bookData) { Book book = bookData.ToBook(); book.BookId = 0; await context.Books.AddAsync(book); await context.SaveChangesAsync(); return(Ok(book)); }
public List <BookEnt> GetBookByName(string nameBook) { var books = new List <BookEnt>(); using (var data = new BookData()) { books = data.GetBookByName(nameBook); } return(books); }
protected override void ProcessElement(BookData bookData, BookContentItemData contentItem, XmlReader xmlReader) { var pageXmlIdRefference = xmlReader.GetAttribute("target"); if (pageXmlIdRefference != null && bookData.Pages != null) { var pageXmlId = pageXmlIdRefference.Substring(1); var bookPage = bookData.Pages.SingleOrDefault(x => x.XmlId == pageXmlId); contentItem.Page = bookPage; } }
public void RemoveSingleForm_HasForm_Removed() { var htmlDom = new HtmlDom(); var data = new BookData(htmlDom, new CollectionSettings(), null); data.Set("1", "one", "en"); var data2 = new BookData(htmlDom, new CollectionSettings(), null); data2.RemoveSingleForm("1", "en"); Assert.IsNull(data2.GetVariableOrNull("1", "en")); }
public List <Book> GetAllBooks() { var list = new List <Book>(); using (var data = new BookData()) { list = data.GetAllBooks(); } return(list); }
public void TestUpdateTerms() { var unitOfWorkProvider = CreateMockUnitOfWorkProvider(); var resourceRepository = new MockResourceRepository(unitOfWorkProvider); var termList = new List <TermData> { new TermData // create term and assign category { XmlId = "null", Position = 0, Text = "new-term", TermCategoryName = "category" }, new TermData // update term and create category { XmlId = "id-1", Position = 0, Text = "updated-term", TermCategoryName = "null" }, new TermData // term and category already exists { XmlId = "id-2", Position = 0, Text = "term", TermCategoryName = "category" } }; var bookData = new BookData { Terms = termList }; var subtask = new UpdateTermsSubtask(resourceRepository); subtask.UpdateTerms(41, bookData); var createdTerms = resourceRepository.CreatedObjects.OfType <Term>().ToList(); var createdCategories = resourceRepository.CreatedObjects.OfType <TermCategory>().ToList(); var updatedTerms = resourceRepository.UpdatedObjects.OfType <Term>().ToList(); var updatedCategories = resourceRepository.UpdatedObjects.OfType <TermCategory>().ToList(); Assert.AreEqual(0, updatedCategories.Count); Assert.AreEqual(1, createdCategories.Count); Assert.AreEqual(1, updatedTerms.Count); Assert.AreEqual(1, createdTerms.Count); Assert.AreEqual("null", createdCategories.First().Name); Assert.AreEqual("new-term", createdTerms.First().Text); Assert.AreEqual("updated-term", updatedTerms.First().Text); }
public void TestUpdateMetadata() { var unitOfWorkProvider = CreateMockUnitOfWorkProvider(); var bookData = new BookData { BookXmlId = "external-id", Title = "title", SourceAbbreviation = "t", PublishPlace = "Praha", ManuscriptDescriptions = new List <ManuscriptDescriptionData>(), Publisher = new PublisherData() }; var metadataRepository = new MockMetadataRepository(unitOfWorkProvider) { CanGetLatestMetadata = true, LatestMetadataVersion = 29 }; var subtask = new UpdateMetadataSubtask(metadataRepository); subtask.UpdateMetadata(40, 1, bookData); var createdMetadata = (MetadataResource)metadataRepository.CreatedObjects.Single(); Assert.AreEqual(30, createdMetadata.VersionNumber); Assert.AreEqual(ContentTypeEnum.None, createdMetadata.Resource.ContentType); Assert.AreEqual(ResourceTypeEnum.ProjectMetadata, createdMetadata.Resource.ResourceType); Assert.AreEqual(createdMetadata, createdMetadata.Resource.LatestVersion); Assert.IsNull(bookData.SubTitle); Assert.AreEqual(bookData.Title, createdMetadata.Title); Assert.AreEqual(bookData.SourceAbbreviation, createdMetadata.SourceAbbreviation); Assert.AreEqual(bookData.PublishPlace, createdMetadata.PublishPlace); metadataRepository = new MockMetadataRepository(unitOfWorkProvider) { CanGetLatestMetadata = false }; subtask = new UpdateMetadataSubtask(metadataRepository); subtask.UpdateMetadata(40, 1, bookData); createdMetadata = (MetadataResource)metadataRepository.CreatedObjects.Single(); Assert.AreEqual(1, createdMetadata.VersionNumber); Assert.AreEqual(ContentTypeEnum.None, createdMetadata.Resource.ContentType); Assert.AreEqual(ResourceTypeEnum.ProjectMetadata, createdMetadata.Resource.ResourceType); Assert.AreEqual(createdMetadata, createdMetadata.Resource.LatestVersion); Assert.IsNull(bookData.SubTitle); Assert.AreEqual(bookData.Title, createdMetadata.Title); Assert.AreEqual(bookData.SourceAbbreviation, createdMetadata.SourceAbbreviation); Assert.AreEqual(bookData.PublishPlace, createdMetadata.PublishPlace); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { BookData ds = new BookData(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public void GetLanguagePrioritiesForLocalizedTextOnPage_DoNotIncludeLang1_OnlyLang1Checked_GetsCorrectListOfLanguages(string lang1, string lang2, string lang3, string[] results) { var settings = CreateCollectionSettings(_folder.Path, "test"); settings.Language1Iso639Code = lang1; settings.Language2Iso639Code = lang2; settings.Language3Iso639Code = lang3; var bookData = new BookData(new HtmlDom("<html><body></body></html>"), settings, null); bookData.SetMultilingualContentLanguages(lang1); Assert.That(bookData.GetLanguagePrioritiesForLocalizedTextOnPage(false), Is.EqualTo(results)); }
public void TestUpdatePageImages() { var unitOfWorkProvider = CreateMockUnitOfWorkProvider(); var resourceRepository = new MockResourceRepository(unitOfWorkProvider); var bookData = new BookData { Pages = new List <BookPageData> { new BookPageData { Text = "39v", Image = "image_39v.jpg" }, new BookPageData { Text = "40r", Image = "image_40r.jpg" } }, FileNameMapping = new Dictionary <string, FileResource> { { "image_39v.jpg", new FileResource { NewNameInStorage = "guid-39v" } }, { "image_40r.jpg", new FileResource { NewNameInStorage = "guid-40r" } }, } }; var subtask = new UpdatePagesSubtask(resourceRepository); subtask.UpdatePages(41, 3, 2, bookData, GetTestTermCache()); var createdImages = resourceRepository.CreatedObjects.OfType <ImageResource>().ToList(); var updatedImages = resourceRepository.UpdatedObjects.OfType <ImageResource>().ToList(); var updatedResources = resourceRepository.UpdatedObjects.OfType <Resource>().ToList(); Assert.AreEqual(2, createdImages.Count); Assert.AreEqual(0, updatedImages.Count); Assert.AreEqual(1, updatedResources.Count); var firstImage = createdImages.First(x => x.FileName == "image_39v.jpg"); var secondImage = createdImages.First(x => x.FileName == "image_40r.jpg"); Assert.AreEqual(1, firstImage.VersionNumber); Assert.AreEqual(2, secondImage.VersionNumber); Assert.AreEqual(900, secondImage.Resource.Id); Assert.IsNotNull(firstImage.FileId); Assert.IsNotNull(firstImage.FileId); Assert.IsTrue(updatedResources[0].IsRemoved); }
public ActionResult Edit(BookData book) { if (book.BookId == 0) { BookStoreService.Instance.Add(book); } else { BookStoreService.Instance.Update(book); } return RedirectToAction("Index"); }
public async Task <bool> UpdateBook(BookData request) { var book = _dataContext.Books.FirstOrDefault(x => x.BookId == request.BookId); book.ISBN = request.ISBN; //book.LongDescr = request.Descr; book.ShortDescr = request.Descr; book.ThumbnailUrl = request.ThumbnailUrl; book.Title = request.Title; book.PublishedDate = request.PublishedDate; return(await _dataContext.SaveChangesAsync() > 0); }
//================================================================== // //================================================================== protected override void OnEnter() { PlayerData playerData = GameController.Instance.PlayerData; BookData bookData = GameController.Instance.BookData[playerData.CurrentBookIndex]; LoadStatBar(playerData, bookData); if (bookData.Unlocked) LoadUpgradePanel(playerData, bookData); else LoadBuyPanel(playerData, bookData); }
public bool UpdateBook(int id, Book book) { var success = false; using (var data = new BookData()) { var result = data.UpdateBook(id, book); success = result; } return(success); }
/// <summary> /// Updates the book data in the bookObject gameObject /// </summary> public void UpdateBookData(BookData bookData) { if(mBookObject != null ) { mBookTitle.text = bookData.BookTitle; mBookAuthor.text = bookData.BookAuthor; mBookRegularPrice.text = string.Format("${0}", bookData.BookRegularPrice); mBookOverallRatings.text = string.Format("( {0} ratings )", bookData.BookOverallRating); mBookYourPrice.text = string.Format("${0}", bookData.BookYourPrice); mBookStarsRating.SetRating(bookData.BookRating); } }
{//chua chinh xac, can kiem tra lai sau public override void BeforeAnimation(ref BookData Data) { Data.TurnTypeManager = TurnType.TurnFromRight; BeforeAnimationBasic(ref Data, Data.iCurrentMenuPage, ref Data.CurrentMenuPage); //#region Next Effect //if (Data.iCurrentMenuPage - 2 >= 0) //{ // Data._previousPageLeftPart = ((TilePage)Data.CurrentMenuPage.ListSubMenu[Data.iCurrentMenuPage - 2]).generatePage(); // Data._previousPageRightPart = ((TilePage)Data.CurrentMenuPage.ListSubMenu[Data.iCurrentMenuPage - 1]).generatePage(); //} //else //{ // Data._previousPageLeftPart = null; // Data._previousPageRightPart = null; //} //if (Data.iCurrentMenuPage + 1 < Data.CurrentMenuPage.ListSubMenu.Count) //{//have 2 left, right pages // Data._nextPageLeftPart = ((TilePage)Data.CurrentMenuPage.ListSubMenu[Data.iCurrentMenuPage]).generatePage(); // Data._nextPageRightPart = ((TilePage)Data.CurrentMenuPage.ListSubMenu[Data.iCurrentMenuPage + 1]).generatePage(); //} //else //{ // if (CurrentMenuItem.ListSubMenu.Count == 1) // { // Data._nextPageRightPart = ((TilePage)CurrentMenuItem.ListSubMenu[iCurrenPage]).generatePage(); // } // else // { // Data._currentPageLeftPage = null; // Data._currentPageRightPage = null; // Data._nextPageLeftPart = null; // Data._nextPageRightPart = null; // } //} //if (Data.iCurrentMenuPage + 3 < Data.CurrentMenuPage.ListSubMenu.Count) //{ // Data.PreNextPageLeftPart = ((TilePage)Data.CurrentMenuPage.ListSubMenu[Data.iCurrentMenuPage + 2]).generatePage(); // Data.PreNextPageRightPart = ((TilePage)Data.CurrentMenuPage.ListSubMenu[Data.iCurrentMenuPage + 3]).generatePage(); //} //else //{ // Data.PreNextPageLeftPart = null; // Data.PreNextPageRightPart = null; //} //#endregion }
public void AmpersandInOriginalCopyrightHandledProperly() { // See http://issues.bloomlibrary.org/youtrack/issue/BL-4585. var dom = new HtmlDom( @"<html> <head><meta name='lockedDownAsShell' content='true'></meta></head> <body> <div id='bloomDataDiv'> <div data-book='copyright' lang='*'> Copyright © 2011, LASI & SILA </div> <div data-book='licenseUrl' lang='en'> http://creativecommons.org/licenses/by-nc-sa/4.0/ </div> </div> <div class='bloom-page cover frontCover outsideFrontCover coverColor bloom-frontMatter A4Landscape layout-style-Default' data-page='required singleton' data-export='front-matter-cover' id='2c97f5ad-24a1-47f0-8b5c-fa2181e1b129'> <div class='bloom-page cover frontCover outsideFrontCover coverColor bloom-frontMatter verso A4Landscape layout-style-Default' data-page='required singleton' data-export='front-matter-credits' id='7a220c97-07e4-47c5-835a-e37dc921f98f'> <div class='marginBox'> <div data-functiononhintclick='bookMetadataEditor' data-hint='Click to Edit Copyright & License' id='versoLicenseAndCopyright' class='bloom-metaData'> <div data-derived='copyright' lang='*' class='copyright'></div> <div data-derived='originalCopyrightAndLicense' lang='en' class='copyright'></div> </div> </div> </div> </div> </body> </html>" ); var metadata = BookCopyrightAndLicense.GetMetadata(dom); var initialCopyright = metadata.CopyrightNotice; Assert.AreEqual("Copyright © 2011, LASI & SILA", initialCopyright); var bookData = new BookData(dom, _collectionSettings, null); BookCopyrightAndLicense.SetOriginalCopyrightAndLicense(dom, bookData, _collectionSettings); var originalCopyright = GetEnglishOriginalCopyrightAndLicense(dom); Assert.AreEqual("Adapted from original, Copyright © 2011, LASI & SILA. Licensed under CC-BY-NC-SA 4.0.", originalCopyright); BookCopyrightAndLicense.UpdateDomFromDataDiv(dom, null, _collectionSettings); var nodes1 = dom.RawDom.SelectNodes("/html/body//div[@data-derived='originalCopyrightAndLicense']"); Assert.AreEqual(1, nodes1.Count); Assert.AreEqual("Adapted from original, Copyright © 2011, LASI & SILA. Licensed under CC-BY-NC-SA 4.0.", nodes1.Item(0).InnerText); Assert.AreEqual("Adapted from original, Copyright © 2011, LASI & SILA. Licensed under CC-BY-NC-SA 4.0.", nodes1.Item(0).InnerXml); var nodes2 = dom.RawDom.SelectNodes("/html/body//div[@data-derived='copyright']"); Assert.AreEqual(1, nodes2.Count); Assert.AreEqual("", nodes2.Item(0).InnerText); Assert.AreEqual("", nodes2.Item(0).InnerXml); AssertOriginalCopyrightAndLicense(dom, "Copyright © 2011, LASI & SILA", "http://creativecommons.org/licenses/by-nc-sa/4.0/"); }
public List<BookList> GetBookList() { List<BookList> BooksList = new List<BookList>(); BookList Record = new BookList(); BookData DataList = new BookData(ConnectionString); var Query = from Table in DataList.BookList select Table; BooksList = Query.ToList<BookList>(); return BooksList; }
public List<BookList> GetBookList(string Keyword) { List<BookList> BooksList = new List<BookList>(); BookList Record = new BookList(); BookData DataList = new BookData(ConnectionString); var Query = from Table in DataList.BookList where Table.BookName.Contains(Keyword) select Table; BooksList = Query.ToList<BookList>(); return BooksList; }
public void Can_Insert_Book() { var book = new BookData() { Author = "Dmitry Novik", Genre = "Fiction", Rating = -1, Title = "A Nightmare on Elm Street" }; BookStoreService.Instance.Add(book); var book2 = BookStoreService.Instance.Search(b => b.Title == "A Nightmare on Elm Street").First(); Assert.AreEqual("Dmitry Novik", book2.Author); Assert.AreEqual("A Nightmare on Elm Street", book2.Title); Assert.AreEqual(-1, book2.Rating); Assert.AreEqual("Fiction", book2.Genre); }
protected override void Perform(SimDescription me, BookData book, bool addToList) { if (!me.ReadBookDataList.ContainsKey(book.ID)) { base.Perform(me, book, addToList); } BookFishData data = book as BookFishData; if (data != null) { Fishing skill = me.SkillManager.GetSkill<Fishing>(SkillNames.Fishing); foreach (FishType type in data.FishTypes) { skill.LearnedAbout(type); } } }
public Item(BookData book, bool read) : base(book.Title, read ? 1 : 0) { mThumbnail = new ThumbnailKey(new ResourceKey((ulong)ResourceUtils.XorFoldHashString32("book_standard"), 0x1661233, 0x1), ThumbnailSize.Medium, ResourceUtils.HashString32(book.GeometryState), ResourceUtils.HashString32(book.MaterialState)); mBook = book; }
protected virtual void Perform(SimDescription me, BookData book, bool addToList) { if (me.ReadBookDataList.ContainsKey(book.ID)) { if (addToList) return; me.ReadBookDataList.Remove(book.ID); } else { if (!addToList) return; ReadBookData readData = new ReadBookData(); readData.BookID = book.ID; readData.TimesRead = 1; me.ReadBookDataList.Add(book.ID, readData); } }
public void Add(BookData book) { WriteBookToStore(x => _store.Add(x), book); }
/// <summary> /// Parses a JSON string and returns a book data struct from that /// </summary> public BookData ParseString(string val) { BookData bookData = new BookData(); string[] jsonLines = val.Split(','); foreach (string line in jsonLines) { string[] elements = line.Split(':'); if(elements.Length > 1) { string jsonKey = GetJSONValue(elements[0]); if(jsonKey.Equals(TITLE_KEY)) { bookData.SetBookTitle(GetJSONValue(elements[1])); } else if(jsonKey.Equals(AUTHOR_KEY)) { bookData.SetBookAuthor(GetJSONValue(elements[1])); } else if(jsonKey.Equals(AVERAGE_RATING_KEY)) { bookData.SetBookRating(int.Parse(GetJSONValue(elements[1]))); } else if(jsonKey.Equals(NUMB_OF_RATINGS_KEY)) { bookData.SetBookOverallRating(int.Parse(GetJSONValue(elements[1]))); } else if(jsonKey.Equals(LIST_PRICE_KEY)) { bookData.SetBookRegularPrice(float.Parse(GetJSONValue(elements[1]))); } else if(jsonKey.Equals(YOUR_PRICE_KEY)) { bookData.SetBookYourPrice(float.Parse(GetJSONValue(elements[1]))); } else if(jsonKey.Equals(THUMB_URL_KEY)) { string thumbUrl = ""; for(int j=1; j < elements.Length; j++) { thumbUrl += elements[j]; if(j == 1) { thumbUrl += ":"; } } bookData.SetBookThumbUrl(GetJSONValue(thumbUrl)); } else if(jsonKey.Equals(BOOK_URL_KEY)) { string bookUrl = ""; for(int j=1; j< elements.Length; j++) { bookUrl += elements[j]; if(j == 1) { bookUrl += ":"; } } bookData.SetBookDetailUrl(GetJSONValue(bookUrl)); } } } return bookData; }
/// <summary> /// fetches the JSON data from a server /// </summary> private IEnumerator LoadJSONBookData(string jsonBookUrl) { // Gets the full book json url string fullBookURL = JsonServerUrl + jsonBookUrl; // Gets the json book info from the url mJsonBookInfo = new WWW(fullBookURL); yield return mJsonBookInfo; // Loading done mIsLoadingBookData = false; if (mJsonBookInfo.error == null) { // Parses the json Object JSONParser parser = new JSONParser(); BookData bookData = parser.ParseString(mJsonBookInfo.text); mBookData = bookData; // Updates the BookData info in the augmented object mBookInformationParser.UpdateBookData(bookData); mIsLoadingBookThumb = true; } else { //Debug.LogError("Error downloading json"); BookData bookData = new BookData(); bookData.SetBookTitle("The Hunger Game"); bookData.SetBookAuthor("Suzanne Collins"); bookData.SetBookRating(4); bookData.SetBookOverallRating(23933); bookData.SetBookRegularPrice(10.99f); bookData.SetBookYourPrice(7.09f); bookData.SetBookThumbUrl("http://ecx.images-amazon.com/images/I/41bOj-am1RL._SX331_BO1,204,203,200_.jpg"); bookData.SetBookDetailUrl("http://www.amazon.com/The-Hunger-Games-Book-1/dp/0439023521/ref=pd_bxgy_14_img_z"); mBookData = bookData; Debug.Log("mBookData assigned"); // Updates the BookData info in the augmented object mBookInformationParser.UpdateBookData(bookData); mIsLoadingBookThumb = true; } }
private void WriteBookToStore(Action<BookData> writeAction, BookData book) { if (writeAction == null) return; if (book == null) throw new ArgumentNullException(nameof(book)); try { AcquireWriterLock(); writeAction(book); UpdateCache(book); } finally { ReleaseWriterLock(); } }
/// <summary> /// Method called when the Close button is pressed /// to clean the target Data /// </summary> public void TargetDeleted() { // Initialize the showing book data variable mIsShowingBookData = false; mIsLoadingBookData = false; mIsLoadingBookThumb = false; mBookData = null; }
//functionforn video streaming private void LoadJSONBookData(string jsonBookUrl) { Debug.Log("inside json parsing "); // Gets the full book json url string fullBookURL = JsonServerUrl + jsonBookUrl; if(!mIsJSONRequested){ // Gets the json book info from the url mJsonBookInfo = new WWW(fullBookURL); mIsJSONRequested = true; Debug.Log(fullBookURL); } //if(mJsonBookInfo.progress >= 1) //{ if(mJsonBookInfo.error == null ) { Debug.Log("json parsing started"); // Parses the json Object JSONParser parser = new JSONParser(); BookData bookData = parser.ParseString(mJsonBookInfo.text); //var str = parser.ParseString(mJsonBookInfo.text); //Debug.Log(str.v); mBookData = bookData; //Debug.Log(mBookData.BookTitle); // Updates state variables //mIsLoadingBookData = false; // Updates the BookData info in the augmented object mBookInformationParser.UpdateBookData(bookData); //mIsLoadingBookThumb = true; }else { Debug.LogError("Error downloading json"); //mIsLoadingBookData = false; } //} }
public Item(BookData book, string key, bool read) : this(book, read) { mKey = key; }
private void UpdateCache(BookData book) { _cache.Set(book.BookId.ToString(), book, CacheExpiryTime); }
public void Update(BookData book) { WriteBookToStore(x => _store.Update(x), book); }