コード例 #1
0
        /// <summary>
        /// プレビュー表示の更新
        /// </summary>
        protected virtual async void RefreshList()
        {
            LstPreview.Items.Clear();
            LblSearching.Show();

            if (currentCTokenSource != null)
            {
                currentCTokenSource.Cancel();
            }
            if (searchTask != null)
            {
                searchTask.Wait();
            }

            var baseDirPath = TxtBaseDirPath.Text;

            // 設定オブジェクトを作成
            var setting = new IgnoreSetting(baseDirPath);
            var lines   = TxtSetting.Text.Replace("\r", "").Split('\n');

            foreach (var line in lines)
            {
                setting.AddPattern(line);
            }

            currentCTokenSource = new CancellationTokenSource();
            searchTask          = Task.Run <List <string> >(() =>
            {
                return(SearchIgnoredFiles(setting, currentCTokenSource.Token));
            });

            var paths = await searchTask;

            // キャンセルされていなければ、画面上にパスを設定
            if (paths != null)
            {
                foreach (var path in paths)
                {
                    LstPreview.Items.Add(path);
                }
            }

            // 進捗表示を隠す
            LblSearching.Hide();
        }
コード例 #2
0
        public void BasicTest()
        {
            foreach (var dataSet in _dataSets)
            {
                foreach (var testPattern in dataSet.TestPatterns)
                {
                    var setting = new IgnoreSetting(dataSet.BaseDirPath);
                    setting.AddPattern(testPattern.Pattern);

                    if (testPattern.ShouldBeMatched)
                    {
                        Assert.IsTrue(setting.IsMatch(dataSet.TargetPath, dataSet.TargetIsDirectory));
                    }
                    else
                    {
                        Assert.IsFalse(setting.IsMatch(dataSet.TargetPath, dataSet.TargetIsDirectory));
                    }
                }
            }
        }