Exemple #1
0
        /// <summary>
        /// 把BlockList.xml反序列化成一个BlockSites实例。
        /// </summary>
        static private BlockSites GetBlockSites()
        {
            string path = string.Format(@"{0}\Resources\BlockList.xml",
                                        Environment.CurrentDirectory);

            return(XMLSerialization <BlockSites> .DeserializeFromXMLToObject(path));
        }
Exemple #2
0
        /// <summary>
        /// 把这实例当XML文件保存。
        /// </summary>
        public void Save()
        {
            string folderPath = string.Format(@"{0}\StoredSites\",
                                              Environment.CurrentDirectory);

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            string filepath = string.Format(@"{0}\{1}.xml", folderPath, this.Host);

            XMLSerialization <StoredSite> .SerializeFromObjectToXML(this, filepath);
        }
Exemple #3
0
        /// <summary>
        ///通过宿主名得到一个存储站点
        /// </summary>
        public static StoredSite GetStoredSite(string host)
        {
            StoredSite storedForm = null;

            string folderPath = string.Format(@"{0}\StoredSites\",
                                              Environment.CurrentDirectory);

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            string filepath = string.Format(@"{0}\{1}.xml", folderPath, host);

            if (File.Exists(filepath))
            {
                storedForm =
                    XMLSerialization <StoredSite> .DeserializeFromXMLToObject(filepath);
            }
            return(storedForm);
        }