Load object data from XML in C# - c#

I have the following class:
[Serializable]
public class SerialAssassin
{
public Hero hero;
public Point heroPB;
public Boss boss;
public Point bossPB;
public Attack attack;
public Point attackPB;
public HPMeter bossHP;
public Point bossHPPB;
public PPMeter heroPP;
public Point heroPPPB;
public Rectangle bossRect;
public Rectangle attackRect;
public int heroState;
public int stepRate;
public int attackDirection;
public int attackLoop;
public int contadorPaso;
public int contadorPasoBoss;
public int bossTop, bossLeft;
public int bossState;
public int bossHealth;
public int bossHPCap;
public int opa;
public int battlesWon;
public int mainBossCounter;
public int ppleft;
public bool paso;
public bool inStadium;
public bool fading;
public bool fightingMainBoss;
public bool fainted;
public string currentPokemon;
}
I'm having problems reading the data from the XML, which was written as follows:
XmlSerializer serializer = new XmlSerializer(typeof(SerialAssassin));
TextWriter textWriter = new StreamWriter(#"..\..\Resources\saveState.xml");
serializer.Serialize(textWriter, serial);
textWriter.Close();
From there, I don't quite know how to read the data. Plus the fact that the XML doesn't serialize the objects of Hero, Boss, Attack, HPMeter, PPMeter.
Hero class:
public class Hero
{
int state = 0;
int x, y;
string path;
Image img;
//methods
}
I'd be grateful if you would be so kind as to explain to me how to load those objects/primitives and then use them.

IIRC, the XmlSerializer checks for properties, not fields. (I think it can use public fields, but you really ought to switch to properties anyway) In addition, classes do not need to be marked as Serializable. (Serializable is used for others such as binary and SOAP serializers)
Replace your fields with properties with public getters and setters. In addition, make sure your other classes (such as Hero, Point, Boss) are all also serializable according to XmlSerializer's rules:
public class SerialAssassin
{
public Hero hero { get; set; }
public Point heroPB { get; set; }
public Boss boss { get; set; }
public int heroState { get; set; }
...
To deserialize, use its Deserialize method (http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.deserialize.aspx):
Stream xmlInputStream = ... //get your file stream, or TextReader, or XmlReader
XmlSerializer deserializer = new XmlSerializer(typeof(SerialAssassin));
SerialAssassin assassin = (SerialAssassin)deserializer.Deserialize(xmlInputStream)
EDIT: Looking at your sample Hero class, it's not serializing any of its values because you have declared them all to be private. Make them public instead.
public class Hero
{
public int state {get; set; }
public int x { get; set; }
public int y { get; set; }
public string path { get; set; }
[XmlIgnore]
public Image img { get; set; }
}
I suspect that Image will not be serializable, so you may want to store the image's file path (or some other identifying information) so you can save/load it. [XmlIgnore] will instruct the XmlSerializer to ignore that property so it doesn't fail during serialization/deserialization.

XmlSerializer serializer = new XmlSerializer(typeof(SerialAssassin));
SerialAssassin assassin;
using(var reader = File.OpenText(#"..\..\Resources\saveState.xml"))
{
assassin = (SerialAssassin)serializer.Deserialize(reader);
}

Related

Parameter values are not getting assigned in class constructor

My Class
[System.Serializable]
public class StallData
{
public StallData(ulong stallID, stallSurfaceTextureData)
{
StallID = stallID;
StallSurfaceTextureData = stallSurfaceTextureData;
}
[field: SerializeField]
public ulong StallID{ get; private set; }
[field: SerializeField]
public StallSurfaceTextureData StallSurfaceTextureData { get; private set; }
}
[System.Serializable]
public class StallSurfaceTextureData
{
public StallSurfaceTextureData( int floorTextureID, int leftTextureID, int right, int back)
{
Debug.LogFormat($" f {floorTextureID} l {leftTextureID} r {right} b {back}");
BackWallTextureID = back;
LeftWallTextureID = leftTextureID;
RightWallTextureID = right;
FloorTextureID = floorTextureID;
}
[field: SerializeField]
public int BackWallTextureID { get; private set; }
[field: SerializeField]
public int LeftWallTextureID { get; private set; }
[field: SerializeField]
public int RightWallTextureID { get;private set; }
[field: SerializeField]
public int FloorTextureID { get; private set; }
}
using newtonsoft-json when I am converting my JSON to this class I am getting back, left & right value 0 and for floor, I am getting the correct value.
I am unable to find the reason for it.
Unity version 2021.3.12f1
this is my JSON
{
"StallID": 889448,
"StallSurfaceTextureData":
{
"BackWallWallTextureID": 0,
"LeftWallWallTextureID": 1,
"RightWallWallTextureID": 2,
"FloorTextureID": 3
}
}
I renamed the parameter name, and one time it worked then again I am getting the same issue.
Edit:
I have changed the parameter name in JSon but still the issue persists. The only way it is working is if I am keeping the parameter name and the variable name inside the class is same. I am not getting how the Parameter name is affecting the value assignment in the class?
for ex:
If I keep my class like this it will work
[System.Serializable]
public class StallSurfaceTextureData
{
public StallSurfaceTextureData( int floorTextureID, int leftWallTextureID, int rightWallTextureID, int backWallTextureID)
{
Debug.LogFormat($" f {floorTextureID} l {leftWallTextureID} r {rightWallTextureID} b {backWallTextureID}".ToGreen());
BackWallTextureID = backWallTextureID;
LeftWallTextureID = leftWallTextureID;
RightWallTextureID = rightWallTextureID;
FloorTextureID = floorTextureID;
}
[field: SerializeField]
public int BackWallTextureID { get; private set; }
[field: SerializeField]
public int LeftWallTextureID { get; private set; }
[field: SerializeField]
public int RightWallTextureID { get;private set; }
[field: SerializeField]
public int FloorTextureID { get; private set; }
}
Unity need to have the same to the letter variables name in JSON and class.
You have BackWallTextureID in JSON and BackWallTextureId in class.
I tried JsonConvert.DeserializeObject(json) - no any problem, I guess because you constructor input parameters are ignored since they are not exist for Newtonsoft.Json. If you want to use a constructor, input parameters should be the same as json ( case insensitive by default).

How to parse complex JSON object in Unity with C# [duplicate]

This question already has answers here:
Serialize and Deserialize Json and Json Array in Unity
(9 answers)
Closed 4 years ago.
^--- For rebuttal of assertion that question is a mere duplicate, see Note at bottom.
spoiler: see bottom of question for final code based on carldevelopsforcoffee's accepted answer that works.
Original question:
I'm attempting to parse a complex JSON file (see below) using C# in Unity (2018.1, VS2015 if it matters) using UnityEngine.JsonUtility.FromJson(). The parser code is listed below.
The top-level variables (sweepIndex, totalRadials, etc) all parse fine into the Sweep object, but the 'radials' array appears to be getting skipped (the List of Radial objects in Sweep ends up null).
If it's not obvious from the JSON, it has the following structure:
A top-level "Sweep" object with 13 simple values and an array of Radial objects.
Each Radial object in the List has 4 simple values, and an array of doubles
Formatted JSON to illustrate structure:
(edited & truncated for clarity... full JSON is String in class below)
{"sweepIndex":0,
"totalRadials":720,
"beamWidth":0.949999988079071,
"startingUnixtime":1536864392000,
"endingUnixtime":1536863574000,
"totalGatesPerRay":1832,
"gateDepthMeters":250.0,
"distanceToFirstGateMeters":2125.0,
"meanElevationDeg":0.5275726318359375,
"originLatitude":33.989444444444445,
"originLongitude":-78.42888888888889,
"originAltitude":20.0,
"deviantOriginCount":0,
"radials": [
{"radialNumber":0,"azimuthDeg":263.21319580078125,"elevationDeg":0.53009033203125,"duration":66521592,
"gateIntensity":[-5.5,-1.0,1.0,3.0,13.5,-15.0,-13.0,-11.5,-10.5,-7.5]},
{"radialNumber":1,"azimuthDeg":263.7432861328125,"elevationDeg":0.5328369140625,"duration":66521616,
"gateIntensity":[-9.5,-1.0,-4.5,-2.5,5.0,-4.0,9.0,-8.5,-1.5,-9.0]}
]}
I'm the one generating the JSON file (using Netcdf-Java to inhale the raw level-2 radar data and spit it out as JSON for the Unity app to consume), so I could probably change the JSON if it made my life enormously easier... but I'd really prefer to not substantially change the overall structure (Sweep Object with array of Radial Objects with array of doubles).
The class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace Assets.Scripts {
public class RadarData {
private String site;
private Sweep sweep;
public RadarData(String site) {
this.site = site;
String src = #"{""sweepIndex"":0,""totalRadials"":720,""beamWidth"":0.949999988079071,""startingUnixtime"":1536863321000,""endingUnixtime"":1536863574000,""totalGatesPerRay"":1832,""gateDepthMeters"":250.0,""distanceToFirstGateMeters"":2125.0,""meanElevationDeg"":0.5275726318359375,""originLatitude"":33.989444444444445,""originLongitude"":-78.42888888888889,""originAltitude"":20.0,""deviantOriginCount"":0,""radials"":[{""radialNumber"":0,""azimuthDeg"":263.21319580078125,""elevationDeg"":0.53009033203125,""duration"":66521592,""gateIntensity"":[-5.5,-1.0,1.0,3.0,13.5,-15.0,-13.0,-11.5,-10.5,-7.5,-5.0,-3.5,-2.0,-19.5,-13.5,-11.0,-9.0,-6.0,-6.0,-6.0,-6.5,-7.0,-3.5,-4.5,-5.5,-6.5,-13.0,-11.0,-9.5,-11.5,-11.5,-11.0,-10.5,-7.0,-5.0,-3.5,-10.5,-9.5,-9.0,-8.5,-1.0,-1.5,-2.5,-4.0,-6.0,-11.5,-5.5,6.5,-0.5,-10.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1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0]}]}";
this.sweep = JsonUtility.FromJson<Sweep>(src);
}
public String toString() {
StringBuilder s = new StringBuilder();
s.AppendFormat("{0} at ({1},{2}), elevation={3}m\n", site, sweep.originLatitude, sweep.originLongitude, sweep.originAltitude);
foreach (Radial r in sweep.radials) {
s.AppendFormat("\tRadial #{0} -- az={1}, el={2}\n", r.radialNumber, r.azimuthDeg, r.elevationDeg);
}
return s.ToString();
}
}
public class Sweep {
public int sweepIndex;
public int totalRadials;
public float beamWidth;
public long startingUnixtime;
public long endingUnixtime;
public int totalGatesPerRay;
public float gateDepthMeters;
public float meanElevationDeg;
public double originLatitude;
public double originLongitude;
public float originAltitude;
public int deviantOriginCount;
public List<Radial> radials;
}
public class Radial {
public int radialNumber;
public float azimuthDeg;
public float elevationDeg;
public long duration;
public List<double> gateIntensity;
}
}
Note:
The question for which the user "Programmer" has stated that this is an alleged duplicate has an answer that doesn't actually solve my stated problem -- complex JSON in Unity. It establishes that Unity's built in JsonUtility class is inadequate for parsing complex JSON, while offering no real alternative.
There are questions on SO about using third-party Json libraries with C#... but using third-party libraries with C# in a Unity project is considerably harder and more specific of a task if they aren't already available as a .unitypackage, especially if it needs to be capable of ultimately working on platforms besides Windows (eg, Android, Magic Leap, Oculus, etc).
That's why the accepted answer to this question is valuable & adds concrete value to SO as a resource... it identifies a solution that addresses the questions's three specific issues -- complex Json, C#, and getting it to work in Unity in a platform-agnostic manner.
Final working code (based on accepted answer)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using JsonFx.Json;
using UnityEditor;
namespace Assets.Scripts {
public class RadarData {
private String site;
private Sweep sweep;
public RadarData(String site) {
this.site = site;
TextAsset src = AssetDatabase.LoadAssetAtPath("Assets/RadarData/" + site + ".json", typeof(TextAsset)) as TextAsset;
var reader = new JsonReader();
dynamic output = reader.Read(src.ToString());
sweep = new Sweep();
sweep.sweepIndex = output["sweepIndex"];
sweep.beamWidth = (float) output["beamWidth"];
sweep.startingUnixtime = output["startingUnixtime"];
sweep.endingUnixtime = output["endingUnixtime"];
sweep.totalGatesPerRay = output["totalGatesPerRay"];
sweep.gateDepthMeters = (float)(output["gateDepthMeters"]);
sweep.meanElevationDeg = (float)(output["meanElevationDeg"]);
sweep.originLatitude = (float)(output["originLatitude"]);
sweep.originLongitude = (float)(output["originLongitude"]);
sweep.originAltitude = (float)(output["originAltitude"]);
sweep.deviantOriginCount = output["deviantOriginCount"];
Dictionary<String,object>[] radials = output["radials"];
sweep.setRadials(radials);
}
public Sweep getSweep(int sweepNumber) {
return sweep;
}
public String toString() {
return sweep.ToString();
}
}
public class Sweep {
public int sweepIndex;
public int totalRadials;
public float beamWidth;
public long startingUnixtime;
public long endingUnixtime;
public int totalGatesPerRay;
public float gateDepthMeters;
public float meanElevationDeg;
public float originLatitude;
public float originLongitude;
public float originAltitude;
public int deviantOriginCount;
public List<Radial> radials;
public void setRadials(Dictionary<String,object>[] src) {
radials = new List<Radial>();
foreach (Dictionary<String,object> rad in src) {
radials.Add(new Radial(rad));
}
}
override public String ToString() {
StringBuilder s = new StringBuilder();
s.AppendFormat("Sweep[index={0}... {1} Radials]", sweepIndex, radials.Count());
return s.ToString();
}
}
public class Radial {
public int radialNumber;
public double azimuthDeg;
public double elevationDeg;
public long duration;
public double[] gateIntensity;
public Radial(Dictionary<String,object> d) {
radialNumber = (int)(d["radialNumber"]);
azimuthDeg = (double)(d["azimuthDeg"]);
elevationDeg = (double)(d["elevationDeg"]);
duration = long.Parse(d["duration"].ToString());
gateIntensity = (double[])(d["gateIntensity"]);
}
}
}
Copy paste your json and http://json2csharp.com/
You will get this:
public class Radial
{
public int radialNumber { get; set; }
public double azimuthDeg { get; set; }
public double elevationDeg { get; set; }
public int duration { get; set; }
public List<double> gateIntensity { get; set; }
}
public class RootObject
{
public int sweepIndex { get; set; }
public int totalRadials { get; set; }
public double beamWidth { get; set; }
public long startingUnixtime { get; set; }
public long endingUnixtime { get; set; }
public int totalGatesPerRay { get; set; }
public double gateDepthMeters { get; set; }
public double distanceToFirstGateMeters { get; set; }
public double meanElevationDeg { get; set; }
public double originLatitude { get; set; }
public double originLongitude { get; set; }
public double originAltitude { get; set; }
public int deviantOriginCount { get; set; }
public List<Radial> radials { get; set; }
}
Then you can use the JsonUtility but you first need to modify some content.
Add Serializable attribute to each class and remove the property extension to make those basic variables.
[Serializable]
public class Radial
{
public int radialNumber;
public double azimuthDeg;
public double elevationDeg;
public int duration;
public List<double> gateIntensity;
}
[Serializable]
public class RootObject
{
public int sweepIndex;
// same with all following items
}
RootObject is the top class of your json, it has no name in the json so default is generated. You can change RootObject to anything you want like JsonResponse.
This is now ready to use like this:
void Start()
{
string json = GetJsonFile(); // From download or text file
RootObject ro = JsonUtility.FromJson<RootObject>(json);
print( ro.radials[0].radialNumber);
}
I use JsonFx for my data classes in Unity.
Example Class:
using JsonFx.Json;
[Serializable]
[JsonName("MyData")]
public class MyData
{
public int id;
public string name;
public int[] stuff;
}
Sample json:
{
"__Type": "MyData, Assembly-CSharp",
"id": 1,
"name": "new_data",
"stuff" :
[
0,
1,
2
]
}
Creating your data object from json :
// Json to MyData object:
// Assume I downloaded a json file
string jsonData = System.Text.Encoding.UTF8.GetString (www.bytes);
jsonData = jsonData.Trim ();
MyData data = MyData.Deserialize(jsonData);
Creating your json file from a data object
// MyData object to Json
// Use MyData data object
string file = "mydata.json";
JsonWriterSettings settings = new JsonWriterSettings ();
settings.PrettyPrint = true;
settings.TypeHintName = "__Type";
JsonWriter writer = new JsonWriter (file, settings);
writer.Write (data);
writer.TextWriter.Flush ();
writer.TextWriter.Close ();
There is an online service that can auto-convert from Json to Poco, for instance
http://json2csharp.com/
http://jsonutils.com/
https://quicktype.io/
In VisualStudio, there is also a menu that does so:

c# How to transform multiple structs into 1 bigger

i have 6 structs for the player and also for the 5 bots. Everyone of them have some different variables and some that are equal to the other ones.I declare them like this
public struct Player
{
public static int Chips;
public static int Type;
public static int Power;
public static bool bot1Turn;
public static bool bot1FoldTurn;
public static AnchorStyles playerCardsAnchor = AnchorStyles.Bottom;
}
public struct Bot1
{
public static int bot1Chips;
public static int bot1Type;
public static int bot1Power;
public static bool bot1Turn;
public static bool bot1FoldTurn;
public static AnchorStyles bot1CardsAnchor = AnchorStyles.Left;
}
public struct Bot2
{
public static int bot2Chips;
public static int bot2Type;
public static int bot2Power;
public static bool bot2Turn;
public static bool bot2FoldTurn;
public static AnchorStyles bot2CardsAnchor = AnchorStyles.Right;
}
public struct Bot3
{
public static int bot3Chips;
public static int bot3Type;
public static int bot3Power;
public static bool bot3Turn;
public static bool bot3FoldTurn;
public static AnchorStyles bot3CardsAnchor = AnchorStyles.Top;
}
public struct Bot4
{
public static int bot4Chips;
public static int bot4Type;
public static int bot4Power;
public static bool bot4Turn;
public static bool bot4FoldTurn;
public static AnchorStyles bot4CardsAnchor = AnchorStyles.Bottom | AnchorStyles.Right;
}
public struct Bot5
{
public static int bot5Chips;
public static int bot5Type;
public static int bot5Power;
public static bool bot5Turn;
public static bool bot5FoldTurn;
public static AnchorStyles bot5CardsAnchor = AnchorStyles.Top | AnchorStyles.Left;
}
Later on i add the values in a static constructor :
static MainPoker()
{
Player.Chips = 100000;
Player.Power = 0;
Player.Type = -1;
Player.playerTurn = true;
Player.playerFoldTurn = false;
}
Now should i keep all the 6 structs like this, or there's some other way to put them all together ? I'm looking for something like interface but it should also be able to hold static variables .. Any suggestions ?
Structs are value types, while classes are reference types. You almost certainly want to use classes for this type of thing.
You have many properties (which you have implemented as fields) in common between players and bots, and between the different "bot numbers". You decided to give all of those properties different names, which makes it difficult to simplify the code.
Your fields are declared static. I would suggest making them instance fields (or probably instance properties).
If you make those changes, you can use inheritance to put similar things in a common base type
public class Agent
{
public int Chips;
public int Type;
public int Power;
public bool Turn;
public bool FoldTurn;
public AnchorStyles CardsAnchor;
}
public class Player : Agent
{
public Player() { CardsAnchor = AnchorStyles.Bottom; }
// Anything that makes a player different here
}
public class Bot : Agent
{
// Anything that makes a bot different here
public Bot(AnchorStyles style)
{
CardsAnchor = style;
}
}
Player player = new Player();
Bot bot1 = new Bot(AnchorStyles.Left);
Bot bot2 = new Bot(AnchorStyles.Right);
You an use properties in your code rather than fields. They will seem to behave similarly in code consuming the class, but properties afford more flexibility because they provide a layer between the value of something and how it is stored behind the scenes (for example, a property can be calculated based on the value of other properties or multiple backing fields). Using properties, you would instead write
public class Agent
{
public int Chips { get; set; }
public int Type { get; set; }
public int Power { get; set; }
public bool Turn { get; set; }
public bool FoldTurn { get; set; }
public AnchorStyles CardsAnchor { get; set; }
}
You don't want structs, you want classes (except you really want structs, but then you would know it)
and you are mixing classes with instances of classes (objects).
Generate just one Player class and then create instances from it:
public class Player
{
public int Chips { get; set; }
public int Type { get; set; }
public int Power { get; set; }
public bool BotTurn { get; set; }
public bool BotFoldTurn { get; set; }
public AnchorStyles PlayerCardsAnchor { get; }
public Player(AnchorStyles playerCardsAnchor, more parameters for properties)
{
PlayerCardsAnchor = playerCardsAnchor;
// set other properties here
}
}
MainPoker()
{
var player = new Player(AnchorStyles.Bottom, more parameters);
var bot1 = new Player(AnchorStyles.Left, more parameters);
//more bots
}
If you need a static way to acces these, create a static class that holds references to these instances.
public static class PokerTable
{
public static Player Player { get; }
public static Player Bot1 { get; }
// more bots
static PokerTable()
{
Player = new Player(AnchorStyles.Bottom, more parameters);
Bot1 = new Player(AnchorStyles.Left, more parameters);
//more bots
}
}
Then you can access the instances in a static way using
PokerTable.Player.Chips = 10;

No serializer defined for type: System.Windows.Media.Media3D.Point3D

I am trying to serialize some data using protobuf net. During the serialization I am getting an error that No serialization defined for the type Point3D. I found one issue something like this but still unable to implement and resolve it. Link is as follow :- No serializer defined for type: System.Drawing.Color
[ProtoContract]
public class ReturnPanelData
{
[ProtoMember(1)]
public Point3D PlacedPoint3D { get; set; }
[ProtoMember(2)]
public double PlacementAngle { get; set; }
[ProtoMember(3)]
public string PanelName { get; set; }
}
[ProtoContract]
public class ReturnDataType
{
[ProtoMember(1)]
public List<ReturnPanelData> ReturnList { get; set; }
[ProtoMember(2)]
public double RemainderArea { get; set; }
[ProtoMember(3)]
public int Height { get; set; }
[ProtoMember(4)]
public int Width { get; set; }
[ProtoMember(5)]
public Point3D BasePoint3D { get; set; }
}
class Program
{
private static HashSet<ReturnDataType> _processedList = new HashSet<ReturnDataType>();
static void Main(string[] args)
{
using (var file = File.Create(#"D:\SavedPCInfo2.bin"))
{
Serializer.Serialize(file, _processedList);
}
Console.WriteLine("Done");
}
}
I am a begineer in JSON serialization/deserialization. How to resolve this issue ?
If it is not possible to serialize Point3D with Protobuf Net, what are the other options to serialize/deserialize a very big list (having approx 300000 items) ?
First off, protobuf-net is not a JSON serializer. It serializes from and to "Protocol Buffers" - the binary serialization format used by Google for much of their data communications.
That being said, there are several solutions to serialize a type, using protobuf-net, that cannot be decorated with ProtoContract attributes:
When contained by some other type, use a proxy or "shim" property as is shown here, OR
Use a surrogate as is shown here, OR
In runtime teach the RuntimeTypeModel about all serializable fields & properties of the type as described here in the section Serializing without attributes.
For option 2, Since a Point3D is entirely defined by its X, Y and Z coordinates, it's very easy to introduce a serialization surrogate:
[ProtoContract]
struct Point3DSurrogate
{
public Point3DSurrogate(double x, double y, double z) : this()
{
this.X = x;
this.Y = y;
this.Z = z;
}
[ProtoMember(1)]
public double X { get; set; }
[ProtoMember(2)]
public double Y { get; set; }
[ProtoMember(3)]
public double Z { get; set; }
public static implicit operator Point3D(Point3DSurrogate surrogate)
{
return new Point3D(surrogate.X, surrogate.Y, surrogate.Z);
}
public static implicit operator Point3DSurrogate(Point3D point)
{
return new Point3DSurrogate(point.X, point.Y, point.Z);
}
}
And then register it with protobuf-net just once on startup like so:
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(Point3D), false).SetSurrogate(typeof(Point3DSurrogate));
Alternatively, for option 3, in startup you could define a contract for Point3D like so:
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(Point3D), true);
ProtoBuf.Meta.RuntimeTypeModel.Default[typeof(Point3D)].Add(1, "X").Add(2, "Y").Add(3, "Z");
(In my opinion the surrogate is clearer despite requiring more code; defining the protocol entirely in runtime seems too fiddly.)
I don't recommend option 1 since you would need to add proxy properties to all classes that use Point3D.

C# XML Deserialize Array Element Values

I've managed to deserialize my XML for the most part, but I'm stuck on one particular thing. How do I get the value of an element, if it's in an array, and each item in that array has it's own attributes. Let me show you what I have
<BusinessObject Name="BusinessName" RecID="12345">
<FieldList>
<Field Name="Field1">FieldValue1</Field>
<Field Name="Field2">FieldValue2</Field>
</FieldList>
</BusinessObject>
So this is a cut-down version, but shows the basis of the XML. I'm currently having trouble trying to capture "FieldValue1" and "FieldValue2" in their respective Field elements.
[XmlRoot("BusinessObject")]
public sealed class BusinessObject
{
[XmlAttribute("Name")]
public string Name { get; set; }
[XmlAttribute("RecID")]
public string RecID { get; set; }
[XmlElement("FieldList", Type = typeof(FieldList))]
public FieldList FieldList { get; set; }
public BusinessObject()
{
FieldList = null;
}
public static BusinessObject FromXmlString(string xmlString)
{
var reader = new StringReader(xmlString);
var serializer = new XmlSerializer(typeof(BusinessObject));
var instance = (BusinessObject)serializer.Deserialize(reader);
return instance;
}
}
[Serializable]
public class FieldList
{
[XmlElement("Field", Type = typeof(Field))]
public Field[] Fields { get; set; }
public FieldList()
{
Fields = null;
}
}
[Serializable]
public class Field
{
[XmlAttribute("Name")]
public string Name { get; set; }
public Field()
{
}
}
I'm sure it's just something simple that I'm missing, but I was having trouble trying to put my problem into words to perform a relevant search.
Many thanks,
Mark
Thanks for taking a look. Clearly I should play around more before posting here, as I've just managed to get it working. I had to add the following to the Field class:
[Serializable]
public class Field
{
[XmlAttribute("Name")]
public string Name { get; set; }
[XmlText]
public string Value { get; set; }
public Field()
{
}
}
Unfortunately I'm just running on a copy of express here, so I couldn't work out how to use xsd without the command prompt.
Cheers all,
Mark

Categories

Resources