Пример #1
0
        public static CacheListViewItem[] CacheListViewItemListFilter(CacheListViewItem[] cacheListViewItemList)
        {
            List<CacheListViewItem> clist = new List<CacheListViewItem>();

            foreach (CacheListViewItem c in cacheListViewItemList)
            {
                if (!CacheListViewItemFilter(c)) clist.Add(c);
            }

            return clist.ToArray();
        }
Пример #2
0
 public DownloadCommunication(Key key, CacheListViewItem item)
 {
     this.key = key;
     this.item = item;
 }
Пример #3
0
        private static bool CacheListViewItemFilter(CacheListViewItem cacheListViewItem)
        {
            var flist = Settings.Default._filterList.Where(n => n.Effect == true).ToArray();
            if (flist.Length == 0) return false;

            bool? flag = null;

            foreach (Filter f in flist)
            {
                // ファイル名の比較
                if (f.Name.Trim() != "")
                {
                    if (flag == null) flag = true;

                    if (f.Name.Contains("\""))
                    {
                        foreach (Match m in Regex.Matches(f.Name, "\"(.*?)\""))
                        {
                            string mat = m.Value.Trim('\"');
                            flag &= ((!mat.StartsWith("-") && cacheListViewItem.Name.Contains(mat)) || (mat.StartsWith("-") && !cacheListViewItem.Name.Contains(mat.Substring(1))));
                        }
                    }
                    else
                    {
                        flag &= cacheListViewItem.Name.Contains(f.Name);
                    }
                }

                // カテゴリの比較
                if (f.Category != null)
                {
                    if (flag == null) flag = true;

                    foreach (string ss in f.Category)
                    {
                        if (ss != null && ss.Trim() != "")
                        {
                            flag &= cacheListViewItem.Category.Any(n => n != null && n.ToLower() == ss.ToLower());
                        }
                    }
                }

                // IDの比較
                if (f.ID != null && f.ID.Trim() != "")
                {
                    if (flag == null) flag = true;

                    flag &= f.ID == Convert.ToBase64String(HashFunction.HashCreate(cacheListViewItem.PublicKey));
                }

                // ハッシュの比較
                if (f.Hash != null && f.Hash.Length != 0)
                {
                    if (flag == null) flag = true;

                    flag &= BinaryEditor.ArrayEquals(f.Hash, cacheListViewItem.Hash);
                }

                // サイズ上限
                if (f.LimitSize != 0)
                {
                    if (flag == null) flag = true;

                    flag &= f.LimitSize > cacheListViewItem.Size;
                }

                // サイズ下限
                if (f.LowerSize != 0)
                {
                    if (flag == null) flag = true;

                    flag &= f.LowerSize < cacheListViewItem.Size;
                }
            }

            return flag == true ? true : false;
        }