What is the easiest implementation of IDynamicMetaObjectProvider?

I have this scenario ...

1.- I provide a "Dynamic Table" for which users can define fields. Each dynamic table will have as many rows / records as needed, but 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 with the defining fields. Everything works perfectly! BUT...

3.- Since I need to Serialize the content, and DynamicObject is not Serializable, I was forced to generate and migrate a dynamic object when dynamic member access is required. But it is ugly and redundant.

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

After an unsuccessful search request / I apologize for your help ... Can someone give a good example (or link) for this?

+3
source share
2 answers

The solution was to implement custom serialization. Implement the ISerializable interface as well as the deserialization constructor.

It takes less time to implement IDynamicMetaObjectProvider.

+1
source

It seems to me that you are reinventing the ExpandoObject class . Instead, consider a collection for your implementation.

+2

Source: https://habr.com/ru/post/1744509/


All Articles