1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-31 07:26:09 +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("<!--/")) if (tag.StartsWith("<!--") && !tag.StartsWith("<!--/"))
{ {
var name = $"AideDeJeuLib.{tag.Substring(4, tag.Length - 7)}, AideDeJeu"; var name = $"AideDeJeuLib.{tag.Substring(4, tag.Length - 7)}, AideDeJeu";
var type = Type.GetType(name); if(CheckNewItem(name))
if (type != null)
{ {
return true; return true;
} }
//var type = Type.GetType(name);
//if (type != null)
//{
// return true;
//}
} }
} }
} }
return false; 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) public bool IsClosingItem(Block block)
{ {
var htmlBlock = block as HtmlBlock; var htmlBlock = block as HtmlBlock;
@ -264,12 +303,17 @@ namespace AideDeJeu.ViewModels
if (tag.StartsWith("<!--") && !tag.StartsWith("<!--/")) if (tag.StartsWith("<!--") && !tag.StartsWith("<!--/"))
{ {
var name = $"AideDeJeuLib.{tag.Substring(4, tag.Length - 7)}, AideDeJeu"; var name = $"AideDeJeuLib.{tag.Substring(4, tag.Length - 7)}, AideDeJeu";
var type = Type.GetType(name); var instance = CreateNewItem(name);
if (type != null) if(instance != null)
{ {
var instance = Activator.CreateInstance(type) as Item;
return instance; 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(); //throw new NotImplementedException();
} }
public SizeRequest GetNativeSize(VisualElement view, double widthConstraint, double heightConstraint)
{
throw new NotImplementedException();
}
} }
internal class MockDeserializer : IDeserializer internal class MockDeserializer : IDeserializer