Object XmlSerialization with protected property setters

后端 未结 2 1919
我在风中等你
我在风中等你 2021-02-14 09:00

Here is my object


    [Serializable()]
    public class PersistentObject
    {
        public virtual int ID {
            get { return id; }
            protec         


        
2条回答
  •  深忆病人
    2021-02-14 09:39

    Even though it doesn't directly answer your question, note that you can serialize properties with an internal setter. To do that, you need to pre-generate the XML serialization assembly with Sgen.exe, and declare that assembly as "friend" using the InternalsVisibleTo attribute :

    [assembly:InternalsVisibleTo("MyAssembly.XmlSerializers")]
    

提交回复
热议问题