开发者

What is the most simple implementation of IDynamicMetaObjectProvider?

开发者 https://www.devze.com 2022-12-29 06:27 出处:网络
I have this scenario... 1.- I\'m providing a \"Dynamic Table\" for wich users can define Fields. Each Dynamic Table will have as many rows/records as needed, but the Field definitions are centralized

I have this scenario...

1.- I'm providing a "Dynamic Table" for wich users can define Fields. Each Dynamic Table will have as many rows/records as needed, but the Field definitions are centralized.

2.- My Dynamic Row/Record class was inherited from the .NET DLR DynamicObject class, and the underlying storage was a List appropriately associated to the defining fields. Everything works fine! BUT...

3.- Because I need to Serialize the content, and DynamicObject is not Serializable, I was forced to genera开发者_Go百科te and carry a Dynamic Object when dynamic member access is required. But this is ugly and redundant.

So, I need to implement IDynamicMetaObjectProvider myself to achieve dynamic access and serialization together.

After googling/binging unsuccessfully I ask for your help... Can anybody please give a good example (or related link) for doing that?


Sounds to me like you are re-inventing the ExpandoObject class. Consider a collection of those for your implementation instead.


The solution was to implement Custom Serialization. Implement the ISerializable interface, plus the deserialization constructor.

It takes less time that implement IDynamicMetaObjectProvider.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号