public abstract class TemplatedControl : PrivateContainer, IXmlSerializable
{
#region CTOR
- public TemplatedControl () : base() {}
+ public TemplatedControl () : base()
+ {
+ if (Interface.XmlLoaderCount > 0)
+ return;
+ loadTemplate ();
+ }
#endregion
string _template;
this.SetChild (Interface.Load (dt.Path, this));
}else
this.SetChild (template);
-
+
this.ResolveBindings ();
}
-
+
#region IXmlSerializable
public override System.Xml.Schema.XmlSchema GetSchema(){ return null; }
public override void ReadXml(System.Xml.XmlReader reader)
string tmp = subTree.ReadOuterXml ();
//Load template from path set as attribute in templated control
- if (string.IsNullOrEmpty (template)) {
+ if (string.IsNullOrEmpty (template)) {
//seek for template tag first
using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
//load template first if inlined
xr.Read ();
Type t = Type.GetType ("Crow." + xr.Name);
- GraphicObject go = (GraphicObject)Activator.CreateInstance (t);
+ GraphicObject go = (GraphicObject)Activator.CreateInstance (t);
(go as IXmlSerializable).ReadXml (xr);
loadTemplate (go);
xr.Read ();//Template close tag
break;
} else
- xr.ReadInnerXml ();
+ xr.ReadInnerXml ();
}
- }
+ }
} else
loadTemplate (Interface.Load (template, this));
-
+
//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 ();
internal static bool XmlSerializerInit = false;
/// <summary> keep ressource path for debug msg </summary>
internal static string CurrentGOMLPath = "";
+ internal static int XmlLoaderCount = 0;
public static int TabSize = 4;
public static string LineBreak = "\r\n";
public static GraphicObject Load (string path, object hostClass = null)
{
+ Interface.XmlLoaderCount ++;
CurrentGOMLPath = path;
using (Stream stream = GetStreamFromPath (path)) {
return Load(stream, GetTopContainerOfGOMLStream(stream), hostClass);
}
+ Interface.XmlLoaderCount --;
}