EDN Admin
Well-known member
Maybe i am implementing the wrong overrides but i thought overriding OuterXML would handle the rendering of child objects that are XmlElement derived.
Sample Base class: (OuterXML Works)
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using System.ComponentModel;
using System.Xml;
namespace EQ1.Objects {
public class UIPoint : UIElement {
public UIPoint ( UIDocument doc )
: this( doc , "Point" ) {
}
public UIPoint ( UIDocument doc , string name )
: base( "" , name , "" , doc ) {
this.X = 0;
this.Y = 0;
}
public int X {
get;
set;
}
public int Y {
get;
set;
}
public override string OuterXml {
get {
if( this.GetElement( "X" ) == null )
this.AddElement( "X" , this.X.ToString() );
if( this.GetElement( "Y" ) == null )
this.AddElement( "Y" , this.Y.ToString() );
return base.OuterXml;
}
}
}
}[/code]
Sample 1st-Tier Derived class: (OuterXml works)
<pre class="prettyprint public class Frame : UIClass {
public Frame ( UIDocument doc , string name ) : base( doc , name ) {
//Initialization of Properties
}
public Frame ( UIDocument doc )
: this( doc , "Frame" ) {
}
public string Texture {
//Property Get/Set declarations
}
public UIPoint Location {
//Property Get/Set declarations
}
public UISize Size {
//Property Get/Set declarations
}
public UIPoint Hotspot {
//Property Get/Set declarations
}
public int Duration {
//Property Get/Set declarations
}
//TODO: Develop Zero to Many occurences of Shading:RGB
[XmlElement( ElementName = "Shading" , Type = typeof( RGB ) )]
public ArrayList Shading {
//Property Get/Set declarations
}
//TODO: Develop Zero to Many occurences of Specular:RGB
[XmlElement( ElementName = "Specular" , Type = typeof( RGB ) )]
public ArrayList Specular {
get;
set;
}
public override string OuterXml {
get {
if( this.GetElement( "Texture" ) == null ) {
this.AddElement( "Texture" , this.Texture );
}
if( this.GetElement( "Location" ) == null )
this.AppendChild( this.Location );
if( this.GetElement( "Size" ) == null )
this.AppendChild( this.Size );
if( this.GetElement( "Hotspot" ) == null )
this.AppendChild( this.Hotspot );
if( this.GetElement( "Duration" ) == null )
this.AddElement( "Duration" , this.Duration.ToString() );
foreach( RGB shad in this.Shading ) {
this.AppendChild( shad );
}
foreach( RGB spec in this.Specular ) {
this.AppendChild( spec );
}
return base.OuterXml;
}
}
}[/code]
<br/>
Sample 2nd-Tier+ Class: (OuterXml does not output a full child nesting of objects)
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using System.Xml.Serialization;
using System.Xml;
using System.Collections;
namespace EQ1.Elements {
public class Ui2DAnimation : UIClass {
public Ui2DAnimation ( UIDocument doc )
: base(doc, "Ui2DAnimation") {
//Property Initialization log
}
public bool Cycle {
//Property Get/Set logic
}
public bool Grid {
//Property Get/Set logic
}
public bool Vertical {
//Property Get/Set logic
}
public int CellWidth {
//Property Get/Set logic
}
public int CellHeight {
//Property Get/Set logic
}
[XmlElement( ElementName = "Frames" , Type = typeof( Frame ) )]
public ArrayList Frames {
//Property Get/Set logic
}
public override string OuterXml {
get {
if( this.GetElement( "Cycle" ) == null )
this.AddElement( "Cycle" , this.Cycle.ToString() );
if( this.GetElement( "Grid" ) == null )
this.AddElement( "Grid" , this.Grid.ToString() );
if( this.GetElement( "Vertical" ) == null )
this.AddElement( "Vertical" , this.Vertical.ToString() );
if( this.GetElement( "CellWidth" ) == null )
this.AddElement( "CellWidth" , this.CellWidth.ToString() );
if( this.GetElement( "CellHeight" ) == null )
this.AddElement( "CellHeight" , this.CellHeight.ToString() );
foreach( Frame item in this.Frames ) {
//this.InnerXml += item.OuterXml;
this.AppendChild( item );
}
return base.OuterXml;
}
}
}
}[/code]
Any suggestions to design to where i can have all of the properties through all the XmlElement objects be output from the document level?
Source-code segment that is using the OuterXml to output the XML structure:
<pre class="prettyprint Dim doc As New UIDocument()
Dim nd As New Ui2DAnimation(doc)
nd.Cycle = True
nd.Grid = True
nd.Vertical = True
nd.CellWidth = 100
nd.CellHeight = 50
Dim frm As New Frame(doc)
frm.Texture = "something"
Dim sz As New UISize(doc, "Size")
frm.Size = sz
Dim spec As New RGB(doc, "Specular")
frm.Specular.Add(spec)
Dim shad As New RGB(doc, "Shading")
frm.Shading.Add(shad)
nd.Frames.Add(frm)
doc.InnerXml = nd.OuterXml
/**
FormatString method simply sends the UIDocument
to a XmlTextWriter and makes the XML look pretty
**/
txtXMLVerification.Text = FormatString(doc)[/code]
<br/><hr class="sig "I am the reason, Curiosity killed the Cat!" Please be patient, there are times where i do not respond for weeks at a time.
http://www.developerfusion.com/tools/ Developer Fusion Tool
View the full article
Sample Base class: (OuterXML Works)
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using System.ComponentModel;
using System.Xml;
namespace EQ1.Objects {
public class UIPoint : UIElement {
public UIPoint ( UIDocument doc )
: this( doc , "Point" ) {
}
public UIPoint ( UIDocument doc , string name )
: base( "" , name , "" , doc ) {
this.X = 0;
this.Y = 0;
}
public int X {
get;
set;
}
public int Y {
get;
set;
}
public override string OuterXml {
get {
if( this.GetElement( "X" ) == null )
this.AddElement( "X" , this.X.ToString() );
if( this.GetElement( "Y" ) == null )
this.AddElement( "Y" , this.Y.ToString() );
return base.OuterXml;
}
}
}
}[/code]
Sample 1st-Tier Derived class: (OuterXml works)
<pre class="prettyprint public class Frame : UIClass {
public Frame ( UIDocument doc , string name ) : base( doc , name ) {
//Initialization of Properties
}
public Frame ( UIDocument doc )
: this( doc , "Frame" ) {
}
public string Texture {
//Property Get/Set declarations
}
public UIPoint Location {
//Property Get/Set declarations
}
public UISize Size {
//Property Get/Set declarations
}
public UIPoint Hotspot {
//Property Get/Set declarations
}
public int Duration {
//Property Get/Set declarations
}
//TODO: Develop Zero to Many occurences of Shading:RGB
[XmlElement( ElementName = "Shading" , Type = typeof( RGB ) )]
public ArrayList Shading {
//Property Get/Set declarations
}
//TODO: Develop Zero to Many occurences of Specular:RGB
[XmlElement( ElementName = "Specular" , Type = typeof( RGB ) )]
public ArrayList Specular {
get;
set;
}
public override string OuterXml {
get {
if( this.GetElement( "Texture" ) == null ) {
this.AddElement( "Texture" , this.Texture );
}
if( this.GetElement( "Location" ) == null )
this.AppendChild( this.Location );
if( this.GetElement( "Size" ) == null )
this.AppendChild( this.Size );
if( this.GetElement( "Hotspot" ) == null )
this.AppendChild( this.Hotspot );
if( this.GetElement( "Duration" ) == null )
this.AddElement( "Duration" , this.Duration.ToString() );
foreach( RGB shad in this.Shading ) {
this.AppendChild( shad );
}
foreach( RGB spec in this.Specular ) {
this.AppendChild( spec );
}
return base.OuterXml;
}
}
}[/code]
<br/>
Sample 2nd-Tier+ Class: (OuterXml does not output a full child nesting of objects)
<pre class="prettyprint using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using System.Xml.Serialization;
using System.Xml;
using System.Collections;
namespace EQ1.Elements {
public class Ui2DAnimation : UIClass {
public Ui2DAnimation ( UIDocument doc )
: base(doc, "Ui2DAnimation") {
//Property Initialization log
}
public bool Cycle {
//Property Get/Set logic
}
public bool Grid {
//Property Get/Set logic
}
public bool Vertical {
//Property Get/Set logic
}
public int CellWidth {
//Property Get/Set logic
}
public int CellHeight {
//Property Get/Set logic
}
[XmlElement( ElementName = "Frames" , Type = typeof( Frame ) )]
public ArrayList Frames {
//Property Get/Set logic
}
public override string OuterXml {
get {
if( this.GetElement( "Cycle" ) == null )
this.AddElement( "Cycle" , this.Cycle.ToString() );
if( this.GetElement( "Grid" ) == null )
this.AddElement( "Grid" , this.Grid.ToString() );
if( this.GetElement( "Vertical" ) == null )
this.AddElement( "Vertical" , this.Vertical.ToString() );
if( this.GetElement( "CellWidth" ) == null )
this.AddElement( "CellWidth" , this.CellWidth.ToString() );
if( this.GetElement( "CellHeight" ) == null )
this.AddElement( "CellHeight" , this.CellHeight.ToString() );
foreach( Frame item in this.Frames ) {
//this.InnerXml += item.OuterXml;
this.AppendChild( item );
}
return base.OuterXml;
}
}
}
}[/code]
Any suggestions to design to where i can have all of the properties through all the XmlElement objects be output from the document level?
Source-code segment that is using the OuterXml to output the XML structure:
<pre class="prettyprint Dim doc As New UIDocument()
Dim nd As New Ui2DAnimation(doc)
nd.Cycle = True
nd.Grid = True
nd.Vertical = True
nd.CellWidth = 100
nd.CellHeight = 50
Dim frm As New Frame(doc)
frm.Texture = "something"
Dim sz As New UISize(doc, "Size")
frm.Size = sz
Dim spec As New RGB(doc, "Specular")
frm.Specular.Add(spec)
Dim shad As New RGB(doc, "Shading")
frm.Shading.Add(shad)
nd.Frames.Add(frm)
doc.InnerXml = nd.OuterXml
/**
FormatString method simply sends the UIDocument
to a XmlTextWriter and makes the XML look pretty
**/
txtXMLVerification.Text = FormatString(doc)[/code]
<br/><hr class="sig "I am the reason, Curiosity killed the Cat!" Please be patient, there are times where i do not respond for weeks at a time.
http://www.developerfusion.com/tools/ Developer Fusion Tool
View the full article