mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Début de gestion de cache avec Akavache
This commit is contained in:
		
							parent
							
								
									aea9b24493
								
							
						
					
					
						commit
						f741c229a2
					
				
					 6 changed files with 36 additions and 8 deletions
				
			
		|  | @ -26,6 +26,7 @@ namespace AideDeJeu.Droid | ||||||
| 		 | 		 | ||||||
| 		public static void UpdateIdValues() | 		public static void UpdateIdValues() | ||||||
| 		{ | 		{ | ||||||
|  | 			global::Splat.Resource.String.library_name = global::AideDeJeu.Droid.Resource.String.library_name; | ||||||
| 			global::Xamarin.Forms.Platform.Android.Resource.Attribute.actionBarSize = global::AideDeJeu.Droid.Resource.Attribute.actionBarSize; | 			global::Xamarin.Forms.Platform.Android.Resource.Attribute.actionBarSize = global::AideDeJeu.Droid.Resource.Attribute.actionBarSize; | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
|  | @ -3730,6 +3731,9 @@ namespace AideDeJeu.Droid | ||||||
| 			// aapt resource value: 0x7f090038 | 			// aapt resource value: 0x7f090038 | ||||||
| 			public const int character_counter_pattern = 2131296312; | 			public const int character_counter_pattern = 2131296312; | ||||||
| 			 | 			 | ||||||
|  | 			// aapt resource value: 0x7f09003e | ||||||
|  | 			public const int library_name = 2131296318; | ||||||
|  | 			 | ||||||
| 			// aapt resource value: 0x7f090000 | 			// aapt resource value: 0x7f090000 | ||||||
| 			public const int mr_button_content_description = 2131296256; | 			public const int mr_button_content_description = 2131296256; | ||||||
| 			 | 			 | ||||||
|  |  | ||||||
|  | @ -12,7 +12,6 @@ namespace AideDeJeu | ||||||
| 		{ | 		{ | ||||||
| 			InitializeComponent(); | 			InitializeComponent(); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|             MainPage = new NavigationPage(new MainPage()); |             MainPage = new NavigationPage(new MainPage()); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -65,7 +65,7 @@ namespace AideDeJeu.Services | ||||||
|         { |         { | ||||||
|             var scrapper = new Scrappers(); |             var scrapper = new Scrappers(); | ||||||
|             var spells = await scrapper.GetSpells(await scrapper.GetSpellIds("c")); |             var spells = await scrapper.GetSpells(await scrapper.GetSpellIds("c")); | ||||||
|             items = spells.Select(spell => new Item() { Text = spell.Title, Description = spell.Description }).ToList(); |             items = spells.Select(spell => new Item() { Text = spell.Title, Description = spell.DescriptionText }).ToList(); | ||||||
|             return await Task.FromResult(items); |             return await Task.FromResult(items); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -5,7 +5,9 @@ | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
| 
 | 
 | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <PackageReference Include="HtmlAgilityPack" Version="1.8.0" /> |     <PackageReference Include="akavache.core" Version="5.0.0" /> | ||||||
|  |     <PackageReference Include="AkavacheLite" Version="0.3.0" /> | ||||||
|  |     <PackageReference Include="HtmlAgilityPack" Version="1.8.1" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| 
 | 
 | ||||||
| </Project> | </Project> | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| using HtmlAgilityPack; | using Akavache; | ||||||
|  | using HtmlAgilityPack; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using System.Diagnostics; | using System.Diagnostics; | ||||||
|  | @ -9,6 +10,7 @@ using System.Runtime.Serialization; | ||||||
| using System.Runtime.Serialization.Json; | using System.Runtime.Serialization.Json; | ||||||
| using System.Text.RegularExpressions; | using System.Text.RegularExpressions; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
|  | using System.Reactive.Linq; | ||||||
| 
 | 
 | ||||||
| namespace AideDeJeuLib | namespace AideDeJeuLib | ||||||
| { | { | ||||||
|  | @ -77,7 +79,7 @@ namespace AideDeJeuLib | ||||||
|             return spells; |             return spells; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public async Task<Spell> GetSpell(string id) |         public async Task<Spell> GetSpellFromSource(string id) | ||||||
|         { |         { | ||||||
|             string html = null; |             string html = null; | ||||||
|             using (var client = GetHttpClient()) |             using (var client = GetHttpClient()) | ||||||
|  | @ -93,10 +95,17 @@ namespace AideDeJeuLib | ||||||
|             var newSpells = new List<Spell>(); |             var newSpells = new List<Spell>(); | ||||||
|             var divSpell = pack.DocumentNode.SelectNodes("//div[contains(@class,'bloc')]").FirstOrDefault(); |             var divSpell = pack.DocumentNode.SelectNodes("//div[contains(@class,'bloc')]").FirstOrDefault(); | ||||||
|             var newSpell = HtmlDivToSpell(divSpell); |             var newSpell = HtmlDivToSpell(divSpell); | ||||||
| 
 |  | ||||||
|             return newSpell; |             return newSpell; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         public async Task<Spell> GetSpell(string id) | ||||||
|  |         { | ||||||
|  |             BlobCache.ApplicationName = "AkavacheExperiment"; | ||||||
|  |             //await BlobCache.UserAccount.InsertObject(id, newSpell); | ||||||
|  |             var truc = await BlobCache.UserAccount.GetOrFetchObject<Spell>(id, () => GetSpellFromSource(id)); | ||||||
|  |             return truc; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         public Spell HtmlDivToSpell(HtmlNode divSpell) |         public Spell HtmlDivToSpell(HtmlNode divSpell) | ||||||
|         { |         { | ||||||
|             var newSpell = new Spell(); |             var newSpell = new Spell(); | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| using HtmlAgilityPack; | using HtmlAgilityPack; | ||||||
| using System; | using System; | ||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
|  | using System.Runtime.Serialization; | ||||||
| using System.Text; | using System.Text; | ||||||
| using System.Text.RegularExpressions; | using System.Text.RegularExpressions; | ||||||
| 
 | 
 | ||||||
|  | @ -20,8 +21,20 @@ namespace AideDeJeuLib | ||||||
|         public string Range { get; set; } |         public string Range { get; set; } | ||||||
|         public string Components { get; set; } |         public string Components { get; set; } | ||||||
|         public string Duration { get; set; } |         public string Duration { get; set; } | ||||||
|         public string DescriptionHtml { get { return DescriptionDiv?.InnerHtml; } } |         public string DescriptionHtml | ||||||
|         public string Description |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return DescriptionDiv?.InnerHtml; | ||||||
|  |             } | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 HtmlDocument doc = new HtmlDocument(); | ||||||
|  |                 doc.LoadHtml(value); | ||||||
|  |                 DescriptionDiv = doc.DocumentNode; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         public string DescriptionText | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|  | @ -41,6 +54,7 @@ namespace AideDeJeuLib | ||||||
|                 return html; |                 return html; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |         [IgnoreDataMember] | ||||||
|         public HtmlNode DescriptionDiv { get; set; } |         public HtmlNode DescriptionDiv { get; set; } | ||||||
|         public string Overflow { get; set; } |         public string Overflow { get; set; } | ||||||
|         public string NoOverflow { get; set; } |         public string NoOverflow { get; set; } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez