Implementing persistence of a symbol in an AddIn

587
1
04-23-2013 03:25 AM
SandyReuther
New Contributor II
Hey there,

I would like my map document to save a user chosen symbol. Therefore I want to implement persistence in my AddIn. There is an example in ArcObjects 10.1 Help, which is unfortunately missing an important piece: PersistHelper class. Does anybody have an example of persisting custom types in AddIns?

Thanks and best regards
S. Reuther



http://resources.arcgis.com/en/help/arcobjects-net/conceptualHelp/#/Add_in_coding_patterns/000100000...

Quote of help content:

[... To store custom types and object graphs, use the ArcObjects PersistHelper class. The following code example shows an extension writing a private struct, which manages an ArcObjects type:[C#]private MyPersistentData _data;

protected override void OnLoad(Stream inStrm)
{
// Initialize the struct.
_data.Location = "";
_data.Point = new ESRI.ArcGIS.Geometry.PointClass();

PersistHelper.Load < MyPersistentData > (inStrm, ref _data);
}

protected override void OnSave(Stream outStrm)
{
PersistHelper.Save < MyPersistentData > (outStrm, _data);
}

[Serializable()]
private struct MyPersistentData
{
public string Location;
public ESRI.ArcGIS.Geometry.PointClass Point;
} ...]
0 Kudos
1 Reply
MauricioPérez_Valverde
New Contributor
Took me quite a while to figure this out, but just in case this happens to someone else I post the reference.

This link: http://www.techques.com/question/26-29791/Alternatives-to-IPersistVariant-in-ArcMap-add-in%27s has the answer. Use the PersistenceHelper class.
0 Kudos