#94 and close #91. Make bookmark as plugin.

This commit is contained in:
qianlifeng
2014-06-30 18:05:42 +08:00
parent 7aca726c33
commit d23eb291f7
11 changed files with 237 additions and 82 deletions

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wox.Infrastructure;
namespace Wox.Plugin.BrowserBookmark
{
public class Bookmark : IEquatable<Bookmark>, IEqualityComparer<Bookmark>
{
private string m_Name;
public string Name
{
get
{
return m_Name;
}
set
{
m_Name = value;
PinyinName = m_Name.Unidecode();
}
}
public string PinyinName { get; private set; }
public string Url { get; set; }
public string Source { get; set; }
public int Score { get; set; }
/* TODO: since Source maybe unimportant, we just need to compare Name and Url */
public bool Equals(Bookmark other)
{
return Equals(this, other);
}
public bool Equals(Bookmark x, Bookmark y)
{
if (Object.ReferenceEquals(x, y)) return true;
if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
return false;
return x.Name == y.Name && x.Url == y.Url;
}
public int GetHashCode(Bookmark bookmark)
{
if (Object.ReferenceEquals(bookmark, null)) return 0;
int hashName = bookmark.Name == null ? 0 : bookmark.Name.GetHashCode();
int hashUrl = bookmark.Url == null ? 0 : bookmark.Url.GetHashCode();
return hashName ^ hashUrl;
}
public override int GetHashCode()
{
return GetHashCode(this);
}
}
}