1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 14:35:45 +00:00

Nouveau parsing d'items (casse l'appli mais c'est temporaire ;) )

This commit is contained in:
Yan Maniez 2019-02-12 14:00:02 +01:00
parent 3480f5bff0
commit 3fade6090c
2 changed files with 54 additions and 5 deletions

View file

@ -225,17 +225,56 @@ namespace AideDeJeu.ViewModels
if (tag.StartsWith("<!--") && !tag.StartsWith("<!--/"))
{
var name = $"AideDeJeuLib.{tag.Substring(4, tag.Length - 7)}, AideDeJeu";
var type = Type.GetType(name);
if (type != null)
if(CheckNewItem(name))
{
return true;
}
//var type = Type.GetType(name);
//if (type != null)
//{
// return true;
//}
}
}
}
return false;
}
bool CheckNewItem(string itemString)
{
itemString = "MonsterHD Strength=\"10\" Wisdom=\"18\"";
var regex = new Regex("(?<item>\\w+)(\\s+((?<name>\\w+)=\"(?<value>.*?)\"))*");
var match = regex.Match(itemString);
var itemName = match.Groups["item"].Value;
var dico = new Dictionary<string, string>();
var names = match.Groups["name"].Captures;
var values = match.Groups["value"].Captures;
for(int i = 0; i<names.Count; i++)
{
dico[names[i].Value] = values[i].Value;
}
var name = itemString;
var type = Type.GetType(name);
if (type != null)
{
return true;
}
return false;
}
Item CreateNewItem(string itemString)
{
var regex = new Regex("(?<item>\\w+)(\\s+((?<name>\\w+)=\"(?<value>.*)\"))*");
var name = itemString;
var type = Type.GetType(name);
if (type != null)
{
var instance = Activator.CreateInstance(type) as Item;
return instance;
}
return null;
}
public bool IsClosingItem(Block block)
{
var htmlBlock = block as HtmlBlock;
@ -264,12 +303,17 @@ namespace AideDeJeu.ViewModels
if (tag.StartsWith("<!--") && !tag.StartsWith("<!--/"))
{
var name = $"AideDeJeuLib.{tag.Substring(4, tag.Length - 7)}, AideDeJeu";
var type = Type.GetType(name);
if (type != null)
var instance = CreateNewItem(name);
if(instance != null)
{
var instance = Activator.CreateInstance(type) as Item;
return instance;
}
//var type = Type.GetType(name);
//if (type != null)
//{
// var instance = Activator.CreateInstance(type) as Item;
// return instance;
//}
}
}
}

View file

@ -124,6 +124,11 @@ namespace Tests.Xamarin.Forms.Mocks
{
//throw new NotImplementedException();
}
public SizeRequest GetNativeSize(VisualElement view, double widthConstraint, double heightConstraint)
{
throw new NotImplementedException();
}
}
internal class MockDeserializer : IDeserializer