Hi,
I'm having a problem with XMLSerializer, I have classes like the
following:
[Serializable]
public abstract class EulerObject
{
private Rectangle rect;
private string guid = "";
public virtual Rectangle Rect
{
get { return rect; }
set{ rect = value; }
}
public string GUID
{
get { return guid; }
set { guid = value; }
}
public abstract void Draw(Graphics g);
public abstract EulerObject MakeCopy(bool sameGuid);
}
[Serializable]
public abstract class EulerShape : EulerObject
{
private GraphicsPath graphPath;
private EulerLabel label = null;
public override Rectangle Rect
{
// do stuff
}
public abstract EulerShapes.Sha peType ShapeType
{
get;// { return shapeType; }
}
[XmlIgnore]
[SoapIgnore]
public GraphicsPath GraphPath
{
// stuff
}
public EulerLabel Label
{
get { return label; }
set { label = value; }
}
public EulerShape() { }
public abstract GraphicsPath CreateGraphicsP ath(Rectangle
rect);
}
[Serializable]
public class EulerShapeElips e : EulerShape
{
public override EulerShapes.Sha peType ShapeType
{
get { return EulerShapes.Sha peType.Elipse; }
}
public EulerShapeElips e() : base() { }
public EulerShapeElips e(Rectangle theRect) : base(theRect) { }
public EulerShapeElips e(String uid, Rectangle theRect) :
base(uid, theRect) { }
public override GraphicsPath CreateGraphicsP ath(Rectangle
rect)
{
GraphicsPath tempPath = new GraphicsPath();
tempPath.AddArc (rect, 0, 360);
return tempPath;
}
public override void Draw(Graphics g)
{
g.DrawPath(Pens .Black, this.GraphPath) ;
if (Label != null)
Label.Draw(g);
}
public override EulerObject MakeCopy(bool keepGuid)
{
EulerShapeElips e tempShape = new
EulerShapeElips e(this.Rect);
if (keepGuid == true)
tempShape.GUID = this.GUID;
return tempShape;
}
}
[Serializable]
public class EulerLabel : EulerObject
{
private string label;
private Font fontUsed;
public XmlFont Font
{
get { return new XmlFont(fontUse d); }
set { fontUsed = value.ToFont(); }
}
[XmlIgnore]
public Font FontUsed
{
get { return fontUsed; }
set { fontUsed = value; }
}
public string Label
{
get { return label; }
set { label = value; }
}
public EulerLabel()
{
this.fontUsed = SystemFonts.Def aultFont;
}
public override void Draw(Graphics g)
{
System.Windows. Forms.TextRende rer.DrawText(g, label,
fontUsed, this.Rect, Color.Black);
}
public override EulerObject MakeCopy(bool keepGuid)
{
EulerLabel tempLabel = new EulerLabel(this .Rect,
this.Label, this.FontUsed);
if (keepGuid == true)
tempLabel.GUID = this.GUID;
return tempLabel;
}
}
//http://www.codeproject .com/soap/xmlsettings.asp
[Serializable]
public struct XmlFont
{
public string FontFamily;
public GraphicsUnit GraphicsUnit;
public float Size;
public FontStyle Style;
public XmlFont(Font f)
{
FontFamily = f.FontFamily.Na me;
GraphicsUnit = f.Unit;
Size = f.Size;
Style = f.Style;
}
public Font ToFont()
{
return new Font(FontFamily , Size, Style,
GraphicsUnit);
}
}
I have a few more classes that inherit from EulerShape.
I have a List<EulerShape that contains various shapes that inherit
from EulerShape.
When using XMLSerializer it wont serialize the Label property inside
the classes based on EulerShape, yet it will serialize the EulerLabel
class itself if its not inside another class.
I've tried telling it to serialize the property by putting
[XmlAttribute(ty peof(EulerLabel ))] above it, but this then causes the
program to crash when trying to serialize it.
If anyone has a solution I'd apprechiate it, I have to try and solve
this problem ASAP so I can continue with a study for my dissertation
involving this application.
Regards,
Kris Wragg
BSc Software Engineering, 4th Year
Sheffield Hallam University 0 2791 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Harris Boyce |
last post by:
Hello,
I'm trying to use the FOR XML EXPLICIT clause with SQL
Server to deserialize data from my database into a
strongly-typed collection object that I will use
throughout my application. I initially tested my design
by building a collection in code and then serializing it
to/from an XML file, which worked fine. However, I have
hit a brick wall trying to restore the data from SQL
Server. I originally had my collection and object
|
by: Chris Aitchison |
last post by:
Hello,
I am attempting to have a class that I have written serialize so that it can
be both passed as a parameter or return value for a webservice, and also be
serialized to disk using the XmlSerializer.
When this class is decalred as a return value for a WebMethod in an XML
WebService I receive the following exception:
System.IO.FileNotFoundException: File or assembly name rexz5r1o.dll, or one
|
by: Andy Neilson |
last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This should have worked fine since the class in question was already being serialized and deserialized as part of a Web service interface. What I found was that by deserializing from an XmlNodeReader instead of an XmlTextReader, XML Serialization doesn't work...
|
by: Loui Mercieca |
last post by:
Hi,
I have created a class, named FormField , which basically contains two
fields, name and value. I have set the tag before the class and the field is set as an
XmlAttribute whil the name as XmlText.
In my main class, i have created an arraylist which contains a collection of
this class FormField. Basically its:
public void Add( string sName, string sValue )
|
by: SJD |
last post by:
I've just read Christoph Schittko's article on XmlSerializer:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp
. . . and very informative it is too.
I, too, am getting nasty FileNotFound exceptions. I've read, and
digested the article, and I think I've found a bug -- it's difficult to
track, though it does happen often.
| |
by: Don McNamara |
last post by:
Hi,
I've hit quite a strange problem with XmlSerializer on my W2K3 server. When
I serialize/deserialize using an exe on my local computer (XP), everything
works fine. When I put the code out on the server (W2K3) it throws an
exception. It only seems to happen when serializing/deserializing _arrays_
of a type. If I just serialize/deserialize one instance, it works fine.
The exception I get is: (sorry for the word wrapping.)...
|
by: Lloyd Dupont |
last post by:
I get an XmlDocument from an external source.
I want to load it/map it to C# class.
I'm creating classes as I learn about the format. many tag are yet unparsed,
but that seems ok for the XmlSerializer, great!
Now here is my problem.
let say my document conceptually map to classes like that:
public class Foo
|
by: Kristopher Wragg |
last post by:
Hi,
I'm having a problem with XMLSerializer, I have classes like the
following:
public abstract class EulerObject
{
private Rectangle rect;
private string guid = "";
|
by: christopher.watford |
last post by:
I'm loading a plugin assembly using Activator.CreateInstanceFrom, and
inside this assembly is a settings class which gets serialized to XML.
The general code flow is as follows:
ObjectHandle pluginHandle = Activator.CreateInstanceFrom(assemblyName,
type);
object plugin = pluginHandle.Unwrap();
....
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |