Created
July 7, 2013 14:00
-
-
Save stoolrossa/5943551 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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