Skip to content

Instantly share code, notes, and snippets.

@stoolrossa
Created July 7, 2013 14:00
Show Gist options
  • Save stoolrossa/5943551 to your computer and use it in GitHub Desktop.
Save stoolrossa/5943551 to your computer and use it in GitHub Desktop.
using System;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.SOESupport;
namespace Blog.SoeExample.Model
{
public class Parcel : IModel
{
public IGeometry Geometry { get; set; }
public string Description { get; set; }
// deserialise from json to set the object properties
public void Deserialise(JsonObject json)
{
JsonObject geometryJson;
if (json.TryGetJsonObject("Geometry", out geometryJson))
{
this.Geometry = Conversion.ToGeometry(geometryJson, esriGeometryType.esriGeometryPolygon);
}
else
{
throw new ArgumentException("No Geometry supplied in Parcel json");
}
string description;
if (json.TryGetString("Description", out description))
{
this.Description = description;
}
else
{
throw new ArgumentException("No Description supplied in Parcel json");
}
}
// serialise the object to json
public JsonObject Serialise()
{
var json = new JsonObject();
json.AddJsonObject("Geometry", Conversion.ToJsonObject(this.Geometry));
json.AddString("Description", this.Description);
return json;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment