问题描述
我想将一些代码从使用 .NET 的 DataContractSerializer
切换到使用 ServiceStack 的 TypeSerializer
以提高速度优势.不幸的是,我继承的代码相当依赖于 OnSerializing
/OnSerialized
/OnDeserializing
/OnDeserialized
,而 ServiceStack 似乎没有打电话.我错过了什么吗?假设不是,是否有一种滥用事物来伪造预期功能的好方法?OnSerialized
/OnDeserialized
可以通过反射粗略近似,但是我对OnSerializing
和OnDeserializing
不知所措.
I want to switch some code from using .NET's DataContractSerializer
to using ServiceStack's TypeSerializer
for the increased speed benefits. Unfortunately, the code I inherited relies rather heavily on OnSerializing
/OnSerialized
/OnDeserializing
/OnDeserialized
, which ServiceStack appears not to call. Am I missing something? Assuming not, is there a good way to abuse things to fake out the intended functionality? OnSerialized
/OnDeserialized
can be roughly approximated through reflection, but I'm at a loss for OnSerializing
and OnDeserializing
.
推荐答案
不,没有这样的设施;您必须使用适当的调用来 fork ServiceStack 或自己进行序列化/反序列化.
No, there is no such facility; you'd have to fork ServiceStack or jacket the serialization/deserialization yourself with appropriate calls.
这篇关于ServiceStack 的 TypeSerializer 是否有 OnDeserializing/OnDeserialized 等价物?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!