Exemplo n.º 1
0
        public void Load(string path)
        {
            if (!File.Exists(path))
                throw new FileNotFoundException("The bookmark file dosen't exists.");

            bookmarkList = new List<BookmarkInfo>();

            BookmarkInfo bookmarkInfo = null;
            String line = null;
            StreamReader reader = null;
            try
            {
                reader = new StreamReader(path, Encoding.UTF8);
                while((line = reader.ReadLine()) != null)
                {
                    line = line.Trim();

                    if (!Regex.IsMatch(line, BookmarkInfo.BOOKMARK_PATTNER))
                    {
                        continue;
                    }

                    bookmarkInfo = new BookmarkInfo();
                    if(bookmarkInfo.Parse(line))
                    {
                        bookmarkList.Add(bookmarkInfo);
                    }
                }
            }
            finally
            {
                if(reader != null) reader.Close();
            }
        }
Exemplo n.º 2
0
        public void Load(string path)
        {
            if (!File.Exists(path))
            {
                throw new FileNotFoundException("The bookmark file dosen't exists.");
            }

            bookmarkList = new List <BookmarkInfo>();

            BookmarkInfo bookmarkInfo = null;
            String       line         = null;
            StreamReader reader       = null;

            try
            {
                reader = new StreamReader(path, Encoding.UTF8);
                while ((line = reader.ReadLine()) != null)
                {
                    line = line.Trim();

                    if (!Regex.IsMatch(line, BookmarkInfo.BOOKMARK_PATTNER))
                    {
                        continue;
                    }

                    bookmarkInfo = new BookmarkInfo();
                    if (bookmarkInfo.Parse(line))
                    {
                        bookmarkList.Add(bookmarkInfo);
                    }
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
 public string BookmarkWrapper(BookmarkInfo info)
 {
     return(String.Format(TEMPLATE_BOOKMARK, info.Url, info.AddDate, info.Icon, info.Title));
 }