aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/TemplatedControl.cs
diff options
context:
space:
mode:
authorj-p <jp.bruyere@live.be>2016-08-11 04:20:36 +0200
committerGitHub <noreply@github.com>2016-08-11 04:20:36 +0200
commit81eb8c7a75ffbe8b6740b2a84a9ebff75da9b393 (patch)
tree3225277358a2bba61c4496923ba39353c942098b /src/GraphicObjects/TemplatedControl.cs
parent4d4a9116ea5c68b27f0b7c43db9682ab57738ae7 (diff)
parent7560c0bb4a769210e289e2633ddf13d2617f8e6e (diff)
Merge pull request #18 from jpbruyere/BindingImprovement
Instantiator
Diffstat (limited to 'src/GraphicObjects/TemplatedControl.cs')
-rw-r--r--src/GraphicObjects/TemplatedControl.cs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs
index b325a0d2..422a45ec 100644
--- a/src/GraphicObjects/TemplatedControl.cs
+++ b/src/GraphicObjects/TemplatedControl.cs
@@ -65,8 +65,8 @@ namespace Crow
string _template;
string _itemTemplate;
- public Dictionary<string, ItemTemplate> ItemTemplates;
-
+ public Dictionary<string, ItemTemplate> ItemTemplates = new Dictionary<string, Crow.ItemTemplate>();//TODO: dont instantiate if not used
+ //but then i should test if null in msil gen
[XmlAttributeAttribute][DefaultValue(null)]
public string Template {
get { return _template; }
@@ -84,7 +84,7 @@ namespace Crow
[XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")]
public string ItemTemplate {
get { return _itemTemplate; }
- set {
+ set {
if (value == _itemTemplate)
return;
@@ -146,7 +146,7 @@ namespace Crow
xr.Read (); //read first child
xr.Read (); //skip root node
- while (!xr.EOF) {
+ while (!xr.EOF) {
if (!xr.IsStartElement ()) {
xr.Read ();
continue;
@@ -164,10 +164,13 @@ namespace Crow
if (ItemTemplates == null)
ItemTemplates = new Dictionary<string, ItemTemplate> ();
- //TODO:check encoding
- ItemTemplates[dataType] = new ItemTemplate (Encoding.UTF8.GetBytes(itemTmp));
+
+ using (IMLReader iTmp = new IMLReader (null, itemTmp)) {
+ ItemTemplates [dataType] =
+ new ItemTemplate (iTmp.RootType, iTmp.GetLoader (), dataType, datas);
+ }
if (!string.IsNullOrEmpty (datas))
- ItemTemplates [dataType].CreateExpandDelegate(this, dataType, datas);
+ ItemTemplates [dataType].CreateExpandDelegate(this);
continue;
}
@@ -197,7 +200,7 @@ namespace Crow
//if no template found, load default one
if (this.child == null)
loadTemplate ();
-
+
//normal xml read
using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
xr.Read ();