Geode本机客户端反序列化PdxInstanceImpl [英] Geode native client deserialise PdxInstanceImpl

查看:112
本文介绍了Geode本机客户端反序列化PdxInstanceImpl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个REST客户端,该客户端用Json数据填充Geode区域,Geode REST API自动将其转换为PdxInstance类型.

I have a REST client that populates a Geode region with Json data which the Geode REST API automatically converts to a PdxInstance type.

该区域触发一个C#本机客户端侦听器AfterCreate(EntryEvent<TKey, TVal> ev),其中TVal类型ev.NewValue被视为类型PdxInstanceImpl,并且看起来像:

The region triggers a C# native client listener AfterCreate(EntryEvent<TKey, TVal> ev) in which the TVal type ev.NewValue is seen as type PdxInstanceImpl and looks like:

PDX[7534066,__GEMFIRE_JSON]{@type=MyClass, Field1=Value1, Field2=Value2}

我从

I've seen from here that the following code can get at the individual Pdx fields

IPdxInstance pdx = (IPdxInstance)ev.NewValue;
pdx.GetField("Field1");

并且可以在字段级别使用,但是我想将接收到的PdxInstanceImpl转换为PdxInstance,以便可以将其直接放入另一个区域,或者我想将所有字段都转换回Json(如一个字符串),然后将Json字符串放入另一个区域,或者按我的喜好使用它.

and that works on a Field level, but I want to convert the PdxInstanceImpl that is received to PdxInstance so it can be put into another region directly, or I want to convert all the fields back to Json (as a string) in 1 go and put a Json string into another region, or use it as I like.

因此,显然有一种方法可以自动将PdxInstance序列化为MyClass,但是如果我尝试

So there is apparently a way to autoserialize a PdxInstance to MyClass but if I try

MyClass c = (MyClass)pdx;

然后我得到System.InvalidCastException: Unable to cast object of type 'Apache.Geode.Client.Internal.PdxInstanceImpl' to type 'MyClass'

我从某些 Java客户端示例,您可以使用PdxInstanceImpl类型获取数据,但是在C#本机客户端中会出现错误:PdxInstanceImpl is inaccessible due to its protection level.

I've seen from some Java client examples you can use type PdxInstanceImpl to get at the data but in the C# native client that gives an error: PdxInstanceImpl is inaccessible due to its protection level.

我添加了 autoserializer ,结果是一样的.

I've added the autoserializer and the results are the same.

知道我在这里缺少什么吗?谢谢

Any idea what I am missing here? Thanks

推荐答案

最后,我使用了逐字段方法:

In the end I've used a field by field approach:

IPdxInstance pdx = (IPdxInstance)ev.NewValue; pdx.GetField("Field1"); pdx.GetField("Field2"); pdx.GetField("Field3"); etc...

IPdxInstance pdx = (IPdxInstance)ev.NewValue; pdx.GetField("Field1"); pdx.GetField("Field2"); pdx.GetField("Field3"); etc...

这篇关于Geode本机客户端反序列化PdxInstanceImpl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆