hdknr / note

Markdown Texts
http://qiita.com/hidelafoglia
7 stars 1 forks source link

Xamarin.iOS: GeometryConverter problem #2

Open hdknr opened 8 years ago

hdknr commented 8 years ago

GeometryConverter

using NetTopologySuite.IO.Converters;
....
[JsonConverter(typeof(GeometryConverter))]
public Point location {get;set;}

GeosConverter: a subclass of GeometryConverter

public class GeosConverter : GeometryConverter
{
  // empty
}
[JsonConverter(typeof(GeosConverter))]
public Point location {get;set;}

Newtonsoft.Json.JsonWriterException: Token StartObject in state Object would result in an invalid JSON object. Path 'location'.

Newtonsoft.Json.JsonWriterException: Token StartObject in state Object would result in an invalid JSON object. Path 'location'.
  at Newtonsoft.Json.JsonWriter.AutoComplete (JsonToken tokenBeingWritten) [0x00048] in <filename unknown>:0
  at Newtonsoft.Json.JsonWriter.InternalWriteStart (JsonToken token, JsonContainerType container) [0x00006] in <filename unknown>:0
  at Newtonsoft.Json.JsonTextWriter.WriteStartObject () [0x00000] in <filename unknown>:0
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.WriteObjectStart (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x00000] in <filename unknown>:0
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x00015] in <filename unknown>:0
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b0] in <filename unknown>:0
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00047] in <filename unknown>:0
  at --- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/2689/962a0506/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in /Users/builder/data/lanes/2689/962a0506/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:994
  at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/UIKit/UIKitSynchronizationContext.cs:24
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/Foundation/NSAction.cs:163
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/UIKit/UIApplication.cs:77
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/2689/962a0506/source/maccore/src/UIKit/UIApplication.cs:61
  at MyApp.iOS.Application.Main (System.String[] args) [0x00008] in /Users/hide/Documents/Lafoglia/MyApp/src/MyApp/MyApp.iOS/Main.cs:1
hdknr commented 8 years ago
The following packages are incompatible with the current project target framework '.NETPortable,Version=v4.5,Profile=Profile78'. 

The packages do not contain any assembly references or content files that are compatible with the current project target framework and may no longer work. 

Retargeting these packages will fail and cause them to be removed from the project.

NetTopologySuite.IO
hdknr commented 8 years ago

NetTopologySuite.IO.GeoJsonWriter

    public class GeosConverter : GeometryConverter
    {
        NetTopologySuite.IO.GeoJsonWriter Writer = new NetTopologySuite.IO.GeoJsonWriter();

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            writer.WriteRawValue (Writer.Write (value));
        }
    }