/// <summary> /// Checks for equality /// </summary> /// <param name="obj"></param> /// <returns>True if pages are equal, false otherwise</returns> public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj == null) { return(false); } // If the object's type is not equal to this type if (GetType() != obj.GetType()) { return(false); } try { // Try to cast IonPage page = (IonPage)obj; // Compare each value return(parent.Equals(page.parent) && identifier.Equals(page.identifier) && collection.Equals(page.collection) && last_changed == page.last_changed && archive.Equals(page.archive) && EqualsUtils.UnorderedEqual(contents, page.contents) && EqualsUtils.UnorderedEqual(children, page.children) && locale.Equals(page.locale) && layout.Equals(page.layout) && position == page.position); } catch { return(false); } }
/// <summary> /// Parses a given pageString to a IonPage /// </summary> /// <param name="pageString"></param> /// <returns>Parsed IonPage</returns> public static IonPage parsePage( string pageString ) { // Parse the page to a raw page container IonPage pageParsed = new IonPage(); try { // Deserialize page IonPageRoot pageParsedNew = JsonConvert.DeserializeObject<IonPageRoot>( pageString ); // Set the first element of the root to be the page pageParsed = pageParsedNew.page[0]; // Sort out empty content pageParsed.sortOutEmptyContent(); } catch( Exception e ) { IonLogging.log( "Error deserializing page json: " + e.Message, IonLogMessageTypes.ERROR ); } return pageParsed; }
/// <summary> /// Saves a pageCacheIndex to cache /// </summary> /// <param name="page"></param> /// <param name="config"></param> public static async Task save( IonPage page, IonConfig config ) { string url = PagesURLs.getPageURL( config, page.identifier ); PageCacheIndex cacheIndex = new PageCacheIndex( url, page.last_changed ); await CacheIndexStore.save<PageCacheIndex>( url, cacheIndex, config ).ConfigureAwait( false ); }
/// <summary> /// Saves a page to the memory cache /// </summary> /// <param name="page"></param> /// <param name="config"></param> public void savePage( IonPage page, IonConfig config ) { string pageUrl = PagesURLs.getPageURL(config, page.identifier); _pageMemoryCache.add(pageUrl, page); }
/// <summary> /// Used to save a page to the memory and isolated storage cache /// </summary> /// <param name="page"></param> /// <param name="config"></param> /// <returns></returns> public async Task savePageToCachesAsync( IonPage page, IonConfig config ) { // Memory cache _memoryCache.savePage( page, _config ); // Local storage cache await StorageUtils.savePageToIsolatedStorageAsync( page, config ).ConfigureAwait( false ); // Save page cache index await PageCacheIndex.save( page, _config ).ConfigureAwait( false ); }