WCF反序列化正在進(jìn)行中。如何在不調(diào)用其構(gòu)造函數(shù)的情況下實(shí)例化數(shù)據(jù)協(xié)定類型的實(shí)例?例如,考慮以下數(shù)據(jù)合同:[DataContract]public sealed class CreateMe{ [DataMember] private readonly string _name; [DataMember] private readonly int _age; private readonly bool _wasConstructorCalled; public CreateMe() { _wasConstructorCalled = true; } // ... other members here}通過(guò)獲取此對(duì)象的實(shí)例時(shí),DataContractSerializer您會(huì)看到字段_wasConstructorCalled為false。那么,WCF如何做到這一點(diǎn)?這是其他人也可以使用的技術(shù),還是對(duì)我們隱藏?
WCF反序列化如何在不調(diào)用構(gòu)造函數(shù)的情況下實(shí)例化對(duì)象?
月關(guān)寶盒
2019-11-27 10:00:04