public uint GetFileRating(byte[] hash) { lock (locker_) { if (FileComments != null) { foreach (FileComments comments in FileComments) { if (string.Compare(comments.Name, MpdUtilities.EncodeHexString(hash)) == 0) { if (comments.Comments != null && comments.Comments.Count > 0) { if (comments.Comments[0].Comment != null) { return(comments.Comments[0].Rate); } else { return(0); } } } } } return(0); } }
public string GetFileComment(byte[] hash) { lock (locker_) { if (FileComments != null) { foreach (FileComments comments in FileComments) { if (string.Compare(comments.Name, MpdUtilities.EncodeHexString(hash)) == 0) { if (comments.Comments != null && comments.Comments.Count > 0) { if (comments.Comments[0].Comment != null) { return(comments.Comments[0].Comment.Substring(0, MAXFILECOMMENTLEN)); } else { return(string.Empty); } } } } } return(string.Empty); } }
public override bool Equals(object obj) { if (obj is MapCKey) { return(MpdUtilities.EncodeHexString(Key).Equals(MpdUtilities.EncodeHexString((obj as MapCKey).Key))); } return(base.Equals(obj)); }
public void SetFileRating(byte[] hash, uint rating) { lock (locker_) { if (FileComments == null) { FileComments = new List <FileComments>(); } bool found = false; foreach (FileComments comments in FileComments) { if (string.Compare(comments.Name, MpdUtilities.EncodeHexString(hash)) == 0) { if (comments.Comments != null && comments.Comments.Count > 0) { comments.Comments[0].Rate = rating; } else { if (comments.Comments == null) { comments.Comments = new List <FileComment>(); } FileComment comment = MuleApplication.Instance.PreferenceObjectManager.CreateFileComment(); comment.Rate = rating; comments.Comments.Add(comment); } found = true; break; } } if (!found) { FileComments comments = MuleApplication.Instance.PreferenceObjectManager.CreateFileComments(MpdUtilities.EncodeHexString(hash)); if (comments.Comments == null) { comments.Comments = new List <FileComment>(); } FileComment comment = MuleApplication.Instance.PreferenceObjectManager.CreateFileComment(); comment.Rate = rating; comments.Comments.Add(comment); FileComments.Add(comments); } } }
public override int GetHashCode() { StringBuilder sb = new StringBuilder(); sb.Append(MpdUtilities.EncodeHexString(hash_)).Append("|"); sb.Append(id_).Append("|") .Append(serverIP_).Append("|") .Append(kadPort_) .Append("|").Append(port_); return(sb.ToString().GetHashCode()); }
public string CreateED2KLink(Mule.File.PartFile pPartFile, bool bEscapeLink) { string link = CreateED2KFileLink(pPartFile.FileName, pPartFile.FileSize.ToString(), MpdUtilities.EncodeHexString(pPartFile.FileHash)).Link; if (!bEscapeLink && link.EndsWith("/")) { return(link.Substring(0, link.Length - 1)); } return(link); }