mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-31 23:45:39 +00:00
Tests sérialization nouveaux bookmarks
This commit is contained in:
parent
f5199f470b
commit
da496a08a9
2 changed files with 93 additions and 55 deletions
|
|
@ -312,17 +312,19 @@ namespace AideDeJeuLib
|
||||||
return post as Item;
|
return post as Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[YamlIgnore]
|
||||||
public virtual string CleanMarkdown
|
public virtual string CleanMarkdown
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var md = Markdown;
|
var md = Markdown ?? string.Empty;
|
||||||
var rx = new Regex("<!--.*?-->");
|
var rx = new Regex("<!--.*?-->");
|
||||||
md = rx.Replace(md, "");
|
md = rx.Replace(md, "");
|
||||||
return md;
|
return md;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[YamlIgnore]
|
||||||
public virtual string NewId
|
public virtual string NewId
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -412,6 +414,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[YamlIgnore]
|
||||||
public virtual OrderedDictionary AttributesKeyValue
|
public virtual OrderedDictionary AttributesKeyValue
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization.Json;
|
using System.Runtime.Serialization.Json;
|
||||||
|
|
@ -17,7 +18,8 @@ namespace AideDeJeu.ViewModels.Library
|
||||||
{
|
{
|
||||||
public BookmarksViewModel()
|
public BookmarksViewModel()
|
||||||
{
|
{
|
||||||
LoadBookmarkCollectionAsync(BookmarkCollectionNames[BookmarkCollectionIndex]).ConfigureAwait(true);
|
//LoadBookmarkCollectionAsync(BookmarkCollectionNames[BookmarkCollectionIndex]).ConfigureAwait(true);
|
||||||
|
LoadBookmarkCollectionsAsync().ConfigureAwait(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<string> BookmarkCollectionNames { get; set; } = new ObservableCollection<string>()
|
public ObservableCollection<string> BookmarkCollectionNames { get; set; } = new ObservableCollection<string>()
|
||||||
|
|
@ -42,6 +44,9 @@ namespace AideDeJeu.ViewModels.Library
|
||||||
//LoadBookmarkCollection(BookmarkCollectionNames[BookmarkCollectionIndex]);
|
//LoadBookmarkCollection(BookmarkCollectionNames[BookmarkCollectionIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, ObservableCollection<Item>> _BookmarkCollections = new Dictionary<string, ObservableCollection<Item>>();
|
||||||
|
|
||||||
private ObservableCollection<Item> _BookmarkCollection = new ObservableCollection<Item>();
|
private ObservableCollection<Item> _BookmarkCollection = new ObservableCollection<Item>();
|
||||||
public ObservableCollection<Item> BookmarkCollection
|
public ObservableCollection<Item> BookmarkCollection
|
||||||
{
|
{
|
||||||
|
|
@ -253,6 +258,36 @@ namespace AideDeJeu.ViewModels.Library
|
||||||
await App.Current.SavePropertiesAsync();
|
await App.Current.SavePropertiesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task InitBookmarkCollectionsAsync()
|
||||||
|
{
|
||||||
|
_BookmarkCollections = new Dictionary<string, ObservableCollection<Item>>()
|
||||||
|
{
|
||||||
|
{ "Général", new ObservableCollection<Item>() },
|
||||||
|
{ "Grimoire", new ObservableCollection<Item>() },
|
||||||
|
{ "Bestiaire", new ObservableCollection<Item>() },
|
||||||
|
{ "Sac", new ObservableCollection<Item>() },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public async Task LoadBookmarkCollectionsAsync()
|
||||||
|
{
|
||||||
|
if(true)
|
||||||
|
{
|
||||||
|
await InitBookmarkCollectionsAsync();
|
||||||
|
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||||
|
{
|
||||||
|
var spells = context.Spells.ToList();
|
||||||
|
var spell = spells.Take(1).FirstOrDefault();
|
||||||
|
_BookmarkCollections["Grimoire"].Add(new Item() { Id = spell.Id, Name = spell.Name });
|
||||||
|
}
|
||||||
|
await SaveBookmarkCollectionsAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task SaveBookmarkCollectionsAsync()
|
||||||
|
{
|
||||||
|
var yaml = new YamlDotNet.Serialization.Serializer().Serialize(_BookmarkCollections);
|
||||||
|
Debug.WriteLine(yaml);
|
||||||
|
}
|
||||||
public string ToString(IEnumerable<Item> items)
|
public string ToString(IEnumerable<Item> items)
|
||||||
{
|
{
|
||||||
string md = string.Empty;
|
string md = string.Empty;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue