0

我在拥有私有领域和公共财产时遇到问题。这就是我装饰班级和财产的方式。

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.Serialization;
using System.Xml.Serialization;

    [DataContract]
    [KnownType(typeof(XDocument))]
    public abstract class DocumentBase
    {
        #region Public Contructors

        /// <summary>
        /// Initialises a new instance of the DocumentBase class
        /// </summary>
        protected DocumentBase()
        {
            Id = Guid.NewGuid();
            Roles = new List<string>();
        }

        #endregion

        #region Private Fields

        /// <summary>
        /// Holds the filename of the document
        /// </summary>
        [DataMember]
        private string fileName;

        private IFileNameCleaner fileNameCleaner;

        #endregion

        #region Protected Properties

        protected IFileNameCleaner FileNameCleaner
        {
            get
            {
                return fileNameCleaner;
            }

            set
            {
                fileNameCleaner = value;
            }
        }

        #endregion

        #region Public Properties

        [DataMember]
        public string FileName
        {
            get
            {
                string newFileName = this.fileName;
                if (FileNamePrefix > 0)
                {
                    newFileName = FileNamePrefix + "_" + fileName;
                }

                return fileNameCleaner.FileName(newFileName);
            }
          private  set
            {
                fileName = value;
            }
        }

错误:

FileName 没有被序列化,谁能告诉我遗漏了什么?

4

1 回答 1

0

从文件名属性,您返回 FileNameCleaner 的 FileName 属性。这个返回的 filenamecleaner.FileName 属性是否可序列化?

于 2013-07-17T18:52:41.720 回答