What I am trying to do is to take an instance of our custom class that is in a general format as shown below:
using System;
using ArcGIS.Core.Geometry;
using ArcGIS.OtherStuff
using SpatialReference = ArcGIS.Core.Geometry.SpatialReference;
namespace myNameSpace
{
public class myClass
{
private bool _field1;
public bool Field1
{
get {return _field1;}
set
{
_field1 = value;
}
}
//So SpatialReference of new shapefile needs to come from NewLayerSpatialRef
private SpatialReference _newLayerSpatialRef;
public SpatialReference NewLayerSpatialRef
{
get { return _newLayerSpatialRef; }
set
{
_newLayerSpatialRef = value;
}
}
..........//Other ArcGIS Pro classes
..........//Other non-ArcGIS Pro classes
}
}
Say I create an instance of this class name myInstance and populate it with all necessary properties.
I would then like to serialize the instance into a file in order to persist it for future use by doing some LIKE the following:
var writer = new StreamWriter(@“c:\temp\myFileForFutureUse.xml”);
XmlSerializer serializer = new XmlSerializer(typeof(myClass));
serializer.Serialize(writer, myInstance);
I don’t necessarily need to use the XmlSerializer class.
Is something like the above possible? Can I serialize an instance of a class that contains instances of ArcGIS Pro classes such as SpatialReference? If so, is there a particular serialization method suggested by Esri such as Xml Serialization or Binary Serialization? Are there any coding examples or white papers? Any guidance on this matter would be appreciated.
Thanks!