Esempio n. 1
0
    /// <summary>
    /// 保存置换表项
    /// </summary>
    /// <param name="flag"></param>
    /// <param name="value"></param>
    /// <param name="depth"></param>
    /// <param name="mv"></param>
    public void RecordHash(int flag, int value, int depth, int mv)
    {
        HashItem hsh = hashTable[situation.Zobr.Key & (HASH_SIZE - 1)];

        if (hsh.Depth > depth)
        {
            return;
        }

        hsh.Flag  = flag;
        hsh.Depth = depth;
        if (value > ChessLogic.WIN_VALUE)
        {
            hsh.MvValue = value + situation.Distance;
        }
        else if (value < -ChessLogic.WIN_VALUE)
        {
            hsh.MvValue = value - situation.Distance;
        }
        else
        {
            hsh.MvValue = value;
        }

        hsh.Mv    = mv;
        hsh.Lock0 = situation.Zobr.Lock0;
        hsh.Lock1 = situation.Zobr.Lock1;
        hashTable[situation.Zobr.Key & (HASH_SIZE - 1)] = hsh;
    }
Esempio n. 2
0
        public HashItem ed2kHash(HashItem item)
        {
            hasher.Clear();
            FileInfo file = new FileInfo(item.Path);

            using (FileStream fs = file.OpenRead())
            {
                AppendDebugLine("Hashing " + item.Name);
                byte[] temp;

                if ((temp = hasher.ComputeHash(fs)) != null)
                {
                    item.Hash = string.Concat(temp.Select(b => b.ToString("x2")).ToArray());
                    AppendDebugLine("Ed2k hash: " + item.Hash);

                    return(item);
                }
                else
                {
                    AppendDebugLine("Hashing aborted");
                }

                return(null);
            }
        }
        public override void Delete(K kulcs)
        {
            HashItem p = A[h(kulcs)];
            HashItem e = null;

            while (p != null && !p.key.Equals(kulcs))
            {
                e = p;
                p = p.next;
            }

            if (p != null)
            {
                if (e == null)
                {
                    A[h(kulcs)] = p.next;
                }
                else
                {
                    e.next = p.next;
                }
            }
            else
            {
                throw new NoSuchKeyHashingException("No such key exists.");
            }
        }
Esempio n. 4
0
        public void MyListAdd(HashItem item)
        {
            Action addToList = new Action(delegate
            {
                string r_msg         = String.Empty;
                APIResponse response = Execute(String.Format("MYLISTADD size={0}&ed2k={1}&viewed={2}&state={3}&edit={4}",
                                                             item.Size, item.Hash, Convert.ToInt32(item.Watched), item.State, Convert.ToInt32(item.Edit)));

                switch (response.Code)
                {
                case RETURN_CODE.MYLIST_ENTRY_ADDED:
                    File(item);
                    r_msg = String.Format("Added {0} to mylist", item.Name);
                    break;

                case RETURN_CODE.MYLIST_ENTRY_EDITED:
                    File(item);
                    r_msg = String.Format("Edited mylist entry for {0}", item.Name);
                    break;

                case RETURN_CODE.FILE_ALREADY_IN_MYLIST:     // TODO: add auto edit to options.
                    item.Edit = true;
                    MyListAdd(item);
                    return;

                case RETURN_CODE.NO_SUCH_FILE:
                    r_msg = "Error! File not in database";
                    break;
                }

                AppendDebugLine(r_msg);
            });

            PrioritizedCommand(addToList);
        }
Esempio n. 5
0
        private void Grow()
        {
            var newSize  = _table.Length << 1;
            var newTable = new HashItem[newSize];

            _table.CopyTo(newTable, 0);
            _table = newTable;
        }
Esempio n. 6
0
 public HashTableWithOpenAddressing(int m) : base(m)
 {
     A = new HashItem[m];
     for (int i = 0; i < m; i++)
     {
         A[i] = new HashItem();
     }
 }
Esempio n. 7
0
 /// <summary>
 /// 初始化置换表
 /// </summary>
 private void InitHashTable()
 {
     //清空置换表
     System.Array.Clear(hashTable, 0, HASH_SIZE);
     for (int i = 0; i < HASH_SIZE; i++)
     {
         hashTable[i] = new HashItem();
     }
 }
Esempio n. 8
0
        private async void PopulateHashItem(HashItem item, AutoResetEvent eventReset)
        {
            FileReport fileReport = null;

            fileReport = await GetFileReportAsyncWithRetries(item.ItemName, 100);

            item._dateTime          = fileReport.ScanDate;
            item.PositiveDetections = fileReport.Scans?.Where(x => x.Value.Detected == true).Select(x => x.ToDetectionDTOMap()).ToList();
            eventReset.Set();
        }
Esempio n. 9
0
        private void OnFileWatched(object sender, FileWatchedArgs e)
        {
            HashItem item = e.Item;

            item.State   = 1;
            item.Watched = item.FromMPC = true;

            lock (m_hashingLock)
                addRowToHashTable(item);
        }
        public override void Insert(K key, T value)
        {
            HashItem newItem = new HashItem();

            newItem.key   = key;
            newItem.value = value;

            newItem.next = A[h(key)];

            A[h(key)] = newItem;
        }
Esempio n. 11
0
        /// <summary>
        /// Used for an entry that is to be inserted into the database
        /// from a recently hashed HashItem.
        /// </summary>
        public FileEntry(HashItem item)
        {
            ed2k = item.Hash;
            size = item.Size;

            if (item.State == 1)
                path = item.Path;

            watched = item.Watched;
            generic = false;
        }
Esempio n. 12
0
 public void Add(object val)
 {
     int key = Hash(val);
     if (Data[key] == null)
         Data[key] = new HashItem(val);
     else
     {
         HashItem Cur = new HashItem(val);
         Cur.Next = Data[key];
         Data[key] = Cur;
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Adds a hashItem to the hash list.
        /// </summary>
        /// <param name="path">Path to file.</param>
        private void addRowToHashTable(HashItem item)
        {
            hashFileList.Insert(0, item);

            if (isHashing)
            {
                totalQueueSize += item.Size;
            }
            else if (!isHashing)
            {
                beginHashing();
            }
        }
Esempio n. 14
0
        public void File(HashItem item)
        {
            Action fileInfo = new Action(delegate
            {
                APIResponse response = Execute(String.Format("FILE size={0}&ed2k={1}&fmask=78006A28B0&amask=F0E0F0C0", item.Size, item.Hash));

                if (response.Code == RETURN_CODE.FILE)
                {
                    ParseFileData(item, response.Message);
                }
            });

            PrioritizedCommand(fileInfo);
        }
Esempio n. 15
0
        /// <summary>
        /// Creates a entry and adds it to the hash list.
        /// </summary>
        /// <param name="path">Path to file.</param>
        private void addRowToHashTable(string path)
        {
            HashItem item = new HashItem(path);

            hashFileList.Add(item);

            if (isHashing)
            {
                totalQueueSize += item.Size;
            }
            else if (!isHashing)
            {
                Dispatcher.BeginInvoke(new Action(delegate { hashingStartButton.IsEnabled = true; }));
            }
        }
Esempio n. 16
0
        //
        // Workshop methodes
        //
        virtual public bool Add(NAW naw)
        {
            /*-Als	deze	plek	al	bezet	is	ga	je	via	linear	probing op	zoek	naar	de	eerstvolgende
             *  geschikte index.
             * -De	methode	retourneert	een	boolean	die	aangeeft	of	het	element	geplaatst	kon
             *  worden.
             * -Het	is	toegestaan	om	meerdere	NAW		objecten	met	dezelfde	naam	(een dus	key)
             * toe	te	voegen.*/

            int newHash = naw.Naam.GetHashCode(); //Something something % modulo

            if (_array == null)
            {
                _array = new Alg1HashItemArray(10);
            }
            int index         = Math.Abs(newHash % Size);
            int originalIndex = index;

            HashItem newItem  = new HashItem(naw.Naam, naw);
            bool     inserted = false;

            while (!inserted)
            {
                if (_array.Size == _used)
                {
                    break;
                }
                if (_array[index] == null || _array[index].IsDeleted)
                {
                    _array[index] = newItem;
                    _used++;
                    inserted = true;
                }
                if (index >= _array.Size - 1)
                {
                    index = 0;
                }
                else
                {
                    index++;
                    if (originalIndex == index)
                    {
                        break;
                    }
                }
            }
            return(inserted);
        }
Esempio n. 17
0
        public override void Insert(K key, T value)
        {
            if (A[h(key)] != null)
            {
                // already in use
                A[h(key)].nextValues.Add(value); // end of the list
            }
            else
            {
                HashItem newItem = new HashItem();
                newItem.key        = key;
                newItem.value      = value;
                newItem.nextValues = new List <T>();

                A[h(key)] = newItem;
            }
        }
Esempio n. 18
0
        public override void Insert(K key, T value)
        {
            if (A[h(key)] != null)
            {
                // item already exists with this KEY
                A[h(key)].nextValues.Add(value); // add to end (!) of the list
            }
            else
            {
                // first item
                HashItem hi = new HashItem();
                hi.key        = key;
                hi.value      = value;
                hi.nextValues = new List <T>();

                A[h(key)] = hi;
            }
        }
        public override T Search(K kulcs)
        {
            HashItem p = A[h(kulcs)];

            while (p != null && !p.key.Equals(kulcs))
            {
                p = p.next;
            }

            if (p != null)
            {
                return(p.value);
            }
            else
            {
                throw new NoSuchKeyHashingException("No such key exists.");
            }
        }
Esempio n. 20
0
        private void RecordHash(int depth, double value, int hashFlag, Decision decision)
        {
            Board board = chessBoard.BitBoard;

            if (hashTable.TryGetValue(board, out var hashItem))
            {
                if (hashItem.depth > depth)
                {
                    return;
                }
            }
            hashTable[board] = new HashItem()
            {
                value    = value,
                hashFlag = hashFlag,
                depth    = depth,
                decision = decision,
            };
        }
Esempio n. 21
0
 public override void Delete(K key)
 {
     if (A[h(key)] == null)
     {
         throw new NoSuchKeyHashingException("No such key exists.");
     }
     else
     {
         HashItem x = A[h(key)];
         if (x.nextValues.Count > 0)
         {
             x.nextValues.RemoveAt(x.nextValues.Count - 1);
         }
         else
         {
             A[h(key)] = null;
         }
     }
 }
Esempio n. 22
0
 public override T Search(K key)
 {
     if (A[h(key)] == null)
     {
         throw new NoSuchKeyHashingException("No such key exists.");
     }
     else
     {
         HashItem x = A[h(key)];
         if (x.nextValues.Count > 0)
         {
             return(x.nextValues.Last());
         }
         else
         {
             return(x.value);
         }
     }
 }
Esempio n. 23
0
        private void OnHashWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            while (hashFileList.Count > 0 && isHashing)
            {
                if (m_HashWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                HashItem thisItem = hashFileList[0],
                         _temp    = m_aniDBAPI.ed2kHash(thisItem);

                if (isHashing && _temp != null) // if we did not abort remove item from queue and process
                {
                    Dispatcher.BeginInvoke(new Action <HashItem>(FinishHash), _temp);
                    removeRowFromHashTable(hashFileList[hashFileList.IndexOf(thisItem)]);
                }
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Adds completed hash item to mylist.
        /// </summary>
        private void FinishHash(HashItem item)
        {
            ppSize += item.Size;

            if (item.FromMPC)
            {
                m_aniDBAPI.MyListAdd(item);

                if (ConfigFile.Read("mpcShowOSD").ToBoolean() && m_mpcAPI != null && m_mpcAPI.isHooked)
                {
                    m_mpcAPI.OSDShowMessage(String.Format("{0}: File marked as watched{1}", m_AppName,
                                                          m_mpcAPI.CurrentFileName != item.Name ? String.Format(", ({0})", item.Name) : String.Empty));
                }
            }
            else if (addToMyListCheckBox.IsChecked == true)
            {
                item.Watched = (bool)watchedCheckBox.IsChecked;
                item.State   = stateComboBox.SelectedIndex;

                m_aniDBAPI.MyListAdd(item);
            }
        }
Esempio n. 25
0
    /// <summary>
    /// 提取置换表项
    /// </summary>
    /// <param name="alpha"></param>
    /// <param name="beta"></param>
    /// <param name="depth"></param>
    /// <param name="mv"></param>
    /// <returns></returns>
    public int ProbeHash(int alpha, int beta, int depth, out int mv)
    {
        //杀棋标志:如果是杀棋,那么不需要满足深度条件
        bool     mate = false;
        HashItem hsh  = hashTable[situation.Zobr.Key & (HASH_SIZE - 1)];

        if (hsh.Lock0 != situation.Zobr.Lock0 || hsh.Lock1 != situation.Zobr.Lock1)
        {
            mv = 0;
            return(-ChessLogic.MATE_VALUE);
        }

        mv = hsh.Mv;
        if (hsh.MvValue > ChessLogic.WIN_VALUE)
        {
            hsh.MvValue -= situation.Distance;
            mate         = true;
        }
        else if (hsh.MvValue < -ChessLogic.WIN_VALUE)
        {
            hsh.MvValue += situation.Distance;
            mate         = true;
        }

        if (hsh.Depth > depth || mate)
        {
            if (hsh.Flag == HASH_BETA)
            {
                return(hsh.MvValue >= beta ? hsh.MvValue : -ChessLogic.MATE_VALUE);
            }
            else if (hsh.Flag == HASH_ALPHA)
            {
                return(hsh.MvValue <= alpha ? hsh.MvValue : -ChessLogic.MATE_VALUE);
            }
            return(hsh.MvValue);
        }

        return(-ChessLogic.MATE_VALUE);
    }
Esempio n. 26
0
        /// <summary>
        /// Removes a hash entry from the list.
        /// </summary>
        /// <param name="item">Item to remove.</param>
        /// <param name="userRemoved">True if removed by user.</param>
        private void removeRowFromHashTable(HashItem item, bool userRemoved = false)
        {
            if (isHashing && userRemoved)
            {
                totalQueueSize -= item.Size;

                if (item == hashFileList[0])
                {
                    m_aniDBAPI.cancelHashing();
                }
            }

            lock (m_hashingLock)
                hashFileList.Remove(item);

            Dispatcher.BeginInvoke(new Action(delegate
            {
                if (hashFileList.Count == 0)
                {
                    hashingStartButton.IsEnabled = hashingStopButton.IsEnabled = false;
                }
            }));
        }
Esempio n. 27
0
        public void Add(TKey key, TValue value)
        {
            if (_table.Length == Count)
            {
                Grow();
            }

            var hash    = GetHash(key);
            var item    = _table[hash];
            var newItem = new HashItem(key, value);

            if (item == null)
            {
                _table[hash] = newItem;
            }
            else
            {
                var tempItem = item;
                while (tempItem != null)
                {
                    if (tempItem.Key.Equals(newItem.Key))
                    {
                        throw new InvalidOperationException($"An item with the same key has already been added: {newItem.Key}");
                    }

                    if (tempItem.Next == null)
                    {
                        tempItem.Next = newItem;
                        break;
                    }

                    tempItem = tempItem.Next;
                }
            }

            Count++;
        }
Esempio n. 28
0
        /// <summary>
        /// Adds completed hash item to mylist.
        /// </summary>
        private void FinishHash(HashItem item)
        {
            ppSize += item.Size;

            if (item.FromMPC)
            {
                m_aniDBAPI.MyListAdd(item);

                if (ConfigFile.Read("mpcShowOSD").ToBoolean() && m_mpcAPI != null && m_mpcAPI.isHooked)
                    m_mpcAPI.OSDShowMessage(String.Format("{0}: File marked as watched{1}", m_AppName,
                        m_mpcAPI.CurrentFileName != item.Name ? String.Format(", ({0})", item.Name) : String.Empty));
            }
            else if (addToMyListCheckBox.IsChecked == true)
            {
                item.Watched = (bool)watchedCheckBox.IsChecked;
                item.State = stateComboBox.SelectedIndex;

                m_aniDBAPI.MyListAdd(item);
            }
        }
Esempio n. 29
0
        public void File(HashItem item)
        {
            Action fileInfo = new Action(delegate
            {
                APIResponse response = Execute(String.Format("FILE size={0}&ed2k={1}&fmask=78006A28B0&amask=F0E0F0C0", item.Size, item.Hash));

                if (response.Code == RETURN_CODE.FILE)
                    ParseFileData(item, response.Message);
            });

            PrioritizedCommand(fileInfo);
        }
Esempio n. 30
0
        /// <summary>
        /// Removes a hash entry from the list.
        /// </summary>
        /// <param name="item">Item to remove.</param>
        /// <param name="userRemoved">True if removed by user.</param>
        private void removeRowFromHashTable(HashItem item, bool userRemoved = false)
        {
            if (isHashing && userRemoved)
            {
                totalQueueSize -= item.Size;

                if (item == hashFileList[0])
                    m_aniDBAPI.cancelHashing();
            }

            lock (m_hashingLock)
                hashFileList.Remove(item);

            Dispatcher.BeginInvoke(new Action(delegate
            {
                if (hashFileList.Count == 0)
                    hashingStartButton.IsEnabled = hashingStopButton.IsEnabled = false;
            }));
        }
Esempio n. 31
0
        public static int CreateDelta(Snapshot from, Snapshot to, int[] outputData)
        {
            var numDeletedItems = 0;
            var numUpdatedItems = 0;
            var numTempItems    = 0;
            var outputOffset    = 3;

            var hashItems = new HashItem[HASHLIST_SIZE];

            for (var i = 0; i < hashItems.Length; i++)
            {
                hashItems[i] = new HashItem();
            }

            GenerateHash(hashItems, to);

            for (var i = 0; i < from.ItemsCount; i++)
            {
                var fromItem = from[i];
                if (GetItemIndexHashed(fromItem.Key, hashItems) == -1)
                {
                    numDeletedItems++;
                    outputData[outputOffset++] = fromItem.Key;
                }
            }

            GenerateHash(hashItems, from);
            var pastIndecies = new int[SnapshotBuilder.MaxItems];

            // fetch previous indices
            // we do this as a separate pass because it helps the cache
            for (var i = 0; i < to.ItemsCount; i++)
            {
                pastIndecies[i] = GetItemIndexHashed(to[i].Key, hashItems);
            }

            for (var i = 0; i < to.ItemsCount; i++)
            {
                var currentItem = to[i];
                var itemSize    = SnapshotItemsInfo.GetSize(currentItem.Item.GetType());

                var pastIndex = pastIndecies[i];

                if (pastIndex != -1)
                {
                    var pastItem = from[pastIndex];
                    var offset   = outputOffset + 3;

                    if (itemSize != 0)
                    {
                        offset = outputOffset + 2;
                    }

                    if (DiffItem(pastItem.Item, currentItem.Item,
                                 outputData, offset) != 0)
                    {
                        outputData[outputOffset++] = (int)currentItem.Item.Type;
                        outputData[outputOffset++] = currentItem.Id;

                        if (itemSize == 0)
                        {
                            outputData[outputOffset++] = itemSize / sizeof(int);
                        }

                        outputOffset += itemSize / sizeof(int); // count item int fields
                        numUpdatedItems++;
                    }
                }
                else
                {
                    outputData[outputOffset++] = (int)currentItem.Item.Type;
                    outputData[outputOffset++] = currentItem.Id;

                    if (itemSize == 0)
                    {
                        outputData[outputOffset++] = itemSize / sizeof(int);
                    }

                    var data   = currentItem.Item.ToArray();
                    var output = outputData.AsSpan(outputOffset, data.Length);
                    data.CopyTo(output);

                    outputOffset += data.Length;
                    numUpdatedItems++;
                }
            }

            if (numDeletedItems == 0 && numUpdatedItems == 0 && numTempItems == 0)
            {
                return(0);
            }

            outputData[0] = numDeletedItems;
            outputData[1] = numUpdatedItems;
            outputData[2] = numTempItems;

            return(outputOffset);
        }
Esempio n. 32
0
 public FileWatchedArgs(string f_Path)
 {
     Item = new HashItem(f_Path);
 }
Esempio n. 33
0
        /// <summary>
        /// Adds a hashItem to the hash list.
        /// </summary>
        /// <param name="path">Path to file.</param>
        private void addRowToHashTable(HashItem item)
        {
            hashFileList.Insert(0, item);

            if (isHashing)
                totalQueueSize += item.Size;
            else if (!isHashing)
                beginHashing();
        }
Esempio n. 34
0
        public static int CreateDelta(Snapshot from, Snapshot to, int[] outputData)
        {
            var numDeletedItems = 0;
            var numUpdatedItems = 0;
            var numTempItems    = 0;
            var outputOffset    = 3;

            var hashItems = new HashItem[HASHLIST_SIZE];

            for (var i = 0; i < hashItems.Length; i++)
            {
                hashItems[i] = new HashItem();
            }

            GenerateHash(hashItems, to);

            // pack deleted stuff
            for (var i = 0; i < from.ItemsCount; i++)
            {
                var fromItem = from[i];
                if (GetItemIndexHashed(fromItem.Key, hashItems) == -1)
                {
                    // deleted
                    numDeletedItems++;
                    outputData[outputOffset++] = fromItem.Key;
                }
            }

            GenerateHash(hashItems, from);
            var pastIndecies = new int[SnapshotBuilder.MAX_SNAPSHOT_ITEMS];

            // fetch previous indices
            // we do this as a separate pass because it helps the cache
            for (var i = 0; i < to.ItemsCount; i++)
            {
                pastIndecies[i] = GetItemIndexHashed(to[i].Key, hashItems);
            }

            for (var i = 0; i < to.ItemsCount; i++)
            {
                var currentItem = to[i];
                var pastIndex   = pastIndecies[i];

                if (pastIndex != -1)
                {
                    var pastItem = from[pastIndex];
                    var offset   = outputOffset + 3;

                    if (SnapObjectsInfo.GetSizeByType(currentItem.Type) != 0)
                    {
                        offset = outputOffset + 2;
                    }

                    if (DiffItem(pastItem.Object, currentItem.Object,
                                 outputData, offset) != 0)
                    {
                        outputData[outputOffset++] = (int)currentItem.Type;
                        outputData[outputOffset++] = currentItem.Id;

                        if (SnapObjectsInfo.GetSizeByType(currentItem.Type) == 0)
                        {
                            outputData[outputOffset++] = currentItem.Object.SerializeLength;
                        }

                        outputOffset += currentItem.Object.SerializeLength; // count item int fields
                        numUpdatedItems++;
                    }
                }
                else
                {
                    outputData[outputOffset++] = (int)currentItem.Type;
                    outputData[outputOffset++] = currentItem.Id;

                    if (SnapObjectsInfo.GetSizeByType(currentItem.Type) == 0)
                    {
                        outputData[outputOffset++] = currentItem.Object.SerializeLength;
                    }

                    var data = currentItem.Object.Serialize();
                    Array.Copy(data, 0, outputData, outputOffset, data.Length);

                    outputOffset += data.Length;
                    numUpdatedItems++;
                }
            }

            if (numDeletedItems == 0 && numUpdatedItems == 0 && numTempItems == 0)
            {
                return(0);
            }

            outputData[0] = numDeletedItems;
            outputData[1] = numUpdatedItems;
            outputData[2] = numTempItems;

            return(outputOffset);
        }
Esempio n. 35
0
        public void MyListAdd(HashItem item)
        {
            Action addToList = new Action(delegate
            {
                string r_msg = String.Empty;
                APIResponse response = Execute(String.Format("MYLISTADD size={0}&ed2k={1}&viewed={2}&state={3}&edit={4}",
                    item.Size, item.Hash, Convert.ToInt32(item.Watched), item.State, Convert.ToInt32(item.Edit)));

                switch (response.Code)
                {
                    case RETURN_CODE.MYLIST_ENTRY_ADDED:
                        File(item);
                        r_msg = String.Format("Added {0} to mylist", item.Name);
                        break;
                    case RETURN_CODE.MYLIST_ENTRY_EDITED:
                        File(item);
                        r_msg = String.Format("Edited mylist entry for {0}", item.Name);
                        break;
                    case RETURN_CODE.FILE_ALREADY_IN_MYLIST: // TODO: add auto edit to options.
                        item.Edit = true;
                        MyListAdd(item);
                        return;
                    case RETURN_CODE.NO_SUCH_FILE:
                        r_msg = "Error! File not in database";
                        break;
                }

                AppendDebugLine(r_msg);
            });

            PrioritizedCommand(addToList);
        }
Esempio n. 36
0
        public HashItem ed2kHash(HashItem item)
        {
            hasher.Clear();
            FileInfo file = new FileInfo(item.Path);

            using (FileStream fs = file.OpenRead())
            {
                AppendDebugLine("Hashing " + item.Name);
                byte[] temp;

                if ((temp = hasher.ComputeHash(fs)) != null)
                {
                    item.Hash = string.Concat(temp.Select(b => b.ToString("x2")).ToArray());
                    AppendDebugLine("Ed2k hash: " + item.Hash);

                    return item;
                }
                else
                    AppendDebugLine("Hashing aborted");

                return null;
            }
        }
Esempio n. 37
0
 public FileWatchedArgs(string f_Path)
 {
     Item = new HashItem(f_Path);
 }
Esempio n. 38
0
        /// <summary>
        /// Creates a entry and adds it to the hash list.
        /// </summary>
        /// <param name="path">Path to file.</param>
        private void addRowToHashTable(string path)
        {
            HashItem item = new HashItem(path);
            hashFileList.Add(item);

            if (isHashing)
                totalQueueSize += item.Size;
            else if (!isHashing)
                Dispatcher.BeginInvoke(new Action(delegate { hashingStartButton.IsEnabled = true; }));
        }