コード例 #1
0
        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);
            }
        }
コード例 #2
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);
            }
        }
コード例 #3
0
ファイル: MapKey.cs プロジェクト: mheydt/mpddotnet
 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));
 }
コード例 #4
0
        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);
                }
            }
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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);
        }