Kaelsin's Profile
Reputation: 0
Apprentice
- Group:
- New Members
- Active Posts:
- 12 (0.01 per day)
- Joined:
- 15-October 09
- Profile Views:
- 215
- Last Active:
May 03 2012 11:28 PM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: Extending a highscore XML class dynamically?
Posted 2 May 2012
Sorry, for not replying earlier. I have not had chance to have a play yet and will look to have go over the next few days or the weekend. Thank you for your great reply baavgai. -
In Topic: Extending a highscore XML class dynamically?
Posted 30 Apr 2012
Thank you for your reply, I have the library being passed a class and saving it to an XML. I'm struggling to load an XML though as it need's to know what the class is, I presume where I have highlighted needs to be the actual class name and not Object? Anyone able to point me in the right direction for this?
public [color="#FF0000"]Object[/color] LoadXMLData(string FileName, object obj) { Object data = obj; var stream = File.Open((string)string.Format("Content/{0}.lst", FileName), FileMode.Open, FileAccess.Read); try { var ser = new System.Xml.Serialization.XmlSerializer(data.GetType()); data = ([color="#FF0000"]Object[/color])ser.Deserialize(stream); } finally { stream.Close(); } return (data); }
Been trying to get this to work for hours and the loading of the XML from a library
bah, posted by accident.
Here is the the code that saves the XML which seems to work fine so far.
public void SaveXMLData(object obj, string hs_FileName) { var m_Object = obj; var stream = File.Open((string)string.Format("Content/{0}.lst", hs_FileName), FileMode.Create); try { ser = new System.Xml.Serialization.XmlSerializer(obj.GetType()); ser.Serialize(stream, m_Object); } finally { stream.Close(); } } -
In Topic: Extending a highscore XML class dynamically?
Posted 29 Apr 2012
lordofduct, on 29 April 2012 - 09:39 AM, said:What would be an easier and more effective tool to put in such a library if you're looking for this kind of extensibility is support for serializing structs defined NOT in the library. So if someone wanted different values saved, they create their own struct and pass it in.
Though technically the existing .net serialization library does most of this for you and is why it exists. You'll essentially be creating a restricted facade to that so the xml always takes the shape you expect.
Sorry, would you be able to elaborate on this a little further? Would this be creating a interface?
I'm not sure where to look for more information/example on this. -
In Topic: Extending a highscore XML class dynamically?
Posted 29 Apr 2012
Just experimenting and trying to get my head round library's.
Just wanted to create a small library where I could load, save and draw a high score table. Just wanted to know if I could add more properties to the struct as at the moment I can only save the players name and score with out hard coding extra properties in to the Library itself. -
In Topic: Extending a highscore XML class dynamically?
Posted 29 Apr 2012
Sorry I was not very clear. I'm looking to add more properties to the existing HighScoreStruct and store them in the XML. So for example at the moment it has name, score and level in the struct - how could I add time as a new property with out re-doing the library each time?
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Private
Friends
Kaelsin hasn't added any friends yet.
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
Kaelsin has no profile comments yet. Why not say hello?