コードを Xamarin mono for Android で動作させるには、次のクラスを Json.Net JsonConverter に書き直す必要があります。
private class ResourceConverter : JavaScriptConverter
{
public ResourceConverter() { }
public override IEnumerable<Type> SupportedTypes
{
get { return new ReadOnlyCollection<Type>(new List<Type>(new Type[] { typeof(SystemCertificate) })); }
}
public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
{
if (dictionary.ContainsKey("Certificate"))
{
SystemCertificate customerResource = new SystemCertificate();
customerResource.SystemID = dictionary["SystemID"].ToString();
string base64Text = dictionary["Certificate"].ToString();
customerResource.Certificate = Convert.FromBase64CharArray(base64Text.ToCharArray(), 0, base64Text.Length);
return customerResource;
}
return null;
}
public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
{
if (obj is SystemCertificate)
{
SystemCertificate systemCertificate = obj as SystemCertificate;
Dictionary<string, object> dic = new Dictionary<string, object>();
dic.Add("SystemID", systemCertificate.SystemID);
return dic;
}
return null;
}
}
問題は、シリアル化のための JsonConverter の基本メソッド (WriteJson) が無効であることです。何をすべきか本当にわかりません。助けてください。
private class ResourceConverterGen2 : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override bool CanConvert(Type objectType)
{
throw new NotImplementedException();
}
}