using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.ComponentModel;

namespace Misc
{
    public interface ITDParam
    {
        string FileName//文件名
        {
            set;
            get;
        }
        string DirectoryName//文件路径
        {
            set;
            get;
        }
        string Path//路径
        {
            set;
            get;
        }
        bool Load(string name);//从本地加载数据
        bool Save(string name);//保存数据到本地
    }
    public abstract class TDParam_Adapter:Misc.ITDParam 
    {
        
        #region ITDParam 成员
        [Browsable(false)]
        public virtual string FileName
        {
            get;
            set;
        }
        [Browsable(false)]
        public virtual string DirectoryName
        {
            get;
            set;
        }
        [Browsable(false)]
        public virtual string Path
        {
            get
            {
                if (string.IsNullOrEmpty(DirectoryName))
                    return FileName;

                return DirectoryName + @"\"+FileName;
            }
            set {
                DirectoryName = System.IO.Path.GetDirectoryName(value);
                FileName = System.IO.Path.GetFileName(value);
            }
        }

        public virtual bool Load(string name)
        {
            if (name != null)
                FileName = name;

            return Misc.SaveToXmlHepler.Load(Path, this);

        }
        public virtual bool Save(string name)
        {
            if (name != null)
                FileName = name;
            

            return Misc.SaveToXmlHepler.Save(Path, this);
        }
        #endregion
    }
}
