Select to view content in your preferred language

.NET 4.0 XmlSerializer and Runtime Objects

3060
3
Jump to solution
09-25-2012 10:33 AM
Labels (1)
EricPaitz
Esri Contributor
Is it possible to Serialize Objects in the ArcGIS Runtime SDK for WPF? I thought this should have worked but it does not.

 SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol() {     Color = new SolidColorBrush(Colors.Red),     Size = 10,     Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle };  using (TextWriter textWriter = new StreamWriter(@"c:\temp\test.xml")) {     XmlSerializer xmlSerializer = new XmlSerializer(simpleMarkerSymbol.GetType());     xmlSerializer.Serialize(textWriter, simpleMarkerSymbol); } 
0 Kudos
1 Solution

Accepted Solutions
AnttiKajanus1
Deactivated User
Hi,

You cannot serialize Symbols since those contains brushes.

If you know exactly what you are going to serialize, you can manually serialize brushes to data object that contains the initialization information.

I have made long time ago extension to serialize GraphicsLayer. You can read more about from http://forums.arcgis.com/threads/59595-I-need-to-be-able-to-add-a-symbol-to-the-map-and-save-it?p=22...

he code is not near perfect but did the job at that time and it was fun test to work with. If you or other people are interested, I could upload the code to GitHub.

View solution in original post

0 Kudos
3 Replies
AnttiKajanus1
Deactivated User
Hi,

You cannot serialize Symbols since those contains brushes.

If you know exactly what you are going to serialize, you can manually serialize brushes to data object that contains the initialization information.

I have made long time ago extension to serialize GraphicsLayer. You can read more about from http://forums.arcgis.com/threads/59595-I-need-to-be-able-to-add-a-symbol-to-the-map-and-save-it?p=22...

he code is not near perfect but did the job at that time and it was fun test to work with. If you or other people are interested, I could upload the code to GitHub.
0 Kudos
JesúsVillajos1
Occasional Contributor
Hi Antti,

I´ve interesting serialize the Graphics into a database, can you upload the code to GitHub.


Thanks Antti,



Hi,

You cannot serialize Symbols since those contains brushes.

If you know exactly what you are going to serialize, you can manually serialize brushes to data object that contains the initialization information.

I have made long time ago extension to serialize GraphicsLayer. You can read more about from http://forums.arcgis.com/threads/59595-I-need-to-be-able-to-add-a-symbol-to-the-map-and-save-it?p=22...

he code is not near perfect but did the job at that time and it was fun test to work with. If you or other people are interested, I could upload the code to GitHub.
0 Kudos
AnttiKajanus1
Deactivated User
Hi Antti,

I´ve interesting serialize the Graphics into a database, can you upload the code to GitHub.

Thanks Antti,


There you go. 😛 As I mentioned previously, I haven't tested that more than the example application so you should do some testing with it. I am also interested if you find it useful or if it blows up.

https://github.com/anttikajanus/Esri/tree/master/RuntimeForWPFExamples/GraphicSerializationExample
0 Kudos