ThinkGeo.com    |     Documentation    |     Premium Support

Problem serializing ShapefileFeatureLayer

As part of the process of upgrading from TG 10 to TG 14 I am testing serialization. The first attempt at serializing a class that inherits from ShapefileFeatureLayer is not working properly. For a number of reasons I am using the latest Beta release of TG. I noticed when de-serializing that some of the properties did not appear to save, for example the ‘Name’ property. I took a look at the XML file that was produced and I can see the problem. Here is a sample:

<?xml version="1.0" encoding="utf-8"?>
    <CustomShapefileFeatureLayer type="ArcGisRestDemo.CustomShapefileFeatureLayer, ArcGisRestDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" hashCode="d3fbf29c-6a2d-485e-90f3-a8eb3fe8a083">
      <redTranslation>0</redTranslation>
      <greenTranslation>0</greenTranslation>
      <blueTranslation>0</blueTranslation>
      <transparency>255</transparency>
      <lh0ProEqualSign>AreasOfConcern</lh0ProEqualSign>
      <lx0ProEqualSign>False</lx0ProEqualSign>
      <mB0ProEqualSign>True</mB0ProEqualSign>
      <mR0ProEqualSign isProperty="true">
        <_ticks>0</_ticks>
      </mR0ProEqualSign>
      <mx0ProEqualSign>DrawException</mx0ProEqualSign>
      <nR0ProEqualSign isProperty="true" />
      <nh0ProEqualSign>False</nh0ProEqualSign>
      <nx0ProEqualSign>False</nx0ProEqualSign>
      <oB0ProEqualSign>Unsafe</oB0ProEqualSign>
      <oR0ProEqualSign isProperty="true" />
      <oh0ProEqualSign>None</oh0ProEqualSign>

Notice that a number of properties are not saved properly in the XML. For example, The ‘Name’ property is
<lh0ProEqualSign>AreasOfConcern</lh0ProEqualSign>
instead of
<name>AreasOfConcern</name>

Looks to me like something is not working properly. Can you help with this?

Thanks!

Steve

Hi Steve,

That’s because the following code didn’t specify the property’s back field name, which is used for the serialization.

public string Name {get; set;} // it’s not using “name” as the back field name

Even the names are kind of messy, they can be correctly deserialized. So I think your concern is the serialized text is not readable, right? The best way is to serialize the public properties but we met some issues before, let us do some research see what we can do.

Thanks,
Ben

Hi Ben,

I don’t care about reading the back field names. But when I use the GeoSerializer to de-serialize, those properties are not being set on the shapefile, even though they are saved in the xml file. Take a look at the sample project included for your convenience.

Thanks!

Steve
ThinkGeo_14_Demo.zip (394.6 KB)

Thanks for the sample. It’s recreated and we are on it.

hi @Steven1,

It’s been fixed. Could you upgrade to ThinkGeo.Core14.3.0-beta049 and give it a try?

Regards,
Leo