c#DataContractSerializer如何克服私人制定者?

时间:2016-06-18 10:46:53

标签: c# serialization datacontractserializer private-members

我的课程名为ID及其'塞特是私人的。我无法理解DataContractSerializer如何能够正确地反序列化流,因为setter是私有的?

    [DataContract(IsReference = true)]
    [KnownType(typeof(FormElementBase))]
    [KnownType(typeof(FormDataElementBase))]
    [KnownType(typeof(FormElementGroupBase))]
    [KnownType(typeof(BoxGroup))]
    [KnownType(typeof(PanelGroup))]
    [KnownType(typeof(PageGroup))]
    [KnownType(typeof(PageGroupContainer))]
    public abstract class ApplicationDomainItemBase 
    {
        protected ApplicationDomainItemBase()
        {

        }

        protected ApplicationDomainItemBase(int id) : this(id, "", "")
        {

        }

        protected ApplicationDomainItemBase(int id, string name, string description)
        {
            _ID = id;
            _Name = name;
            _Description = description;
        }

        [DataMember]
        private int _ID;

        [DataMember]
        public int ID
        {
            get { return _ID; }
            private set
            { }
        }
}

感谢您的帮助。

0 个答案:

没有答案