示例#1
0
 public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
 {
     if (ignoreList == null)
         throw new ArgumentNullException("ignoreList");
     ignoreList.Ignore("*.intellisense.js");
     ignoreList.Ignore("*-vsdoc.js");
 }
 public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
 {
     if (ignoreList == null)
         throw new ArgumentNullException("ignoreList");
     ignoreList.Ignore("*.intellisense.js");
     ignoreList.Ignore("*-vsdoc.js");
     ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
 }
示例#3
0
        private static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
        {
            if (ignoreList == null)
                return;

            ignoreList.Ignore("*.intellisense.js");
            ignoreList.Ignore("*-vsdoc.js");
            ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
        }
示例#4
0
        public static void AddIgnorePaterns(IgnoreList ignoreList)
        {
            if (ignoreList == null)
            {
                throw new ArgumentNullException("ignoreList");
            }

            ignoreList.Ignore("*.min.js", OptimizationMode.WhenEnabled);
        }
示例#5
0
 public static void ResetIgnorePatterns(IgnoreList ignoreList)
 {
     ignoreList.Clear();
     ignoreList.Ignore("*.intellisense.js");
     ignoreList.Ignore("*-vsdoc.js");
     ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
     //ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
     ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
 }
示例#6
0
        private static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
        {
            if (ignoreList == null)
            {
                throw new ArgumentNullException("BundleConfig ignore list.");
            }

            ignoreList.Ignore("*.intellisense.js");
            ignoreList.Ignore("*-vsdoc.js");
        }
示例#7
0
        private static void SetupIgnorePatterns(IgnoreList ignoreList)
        {
            if (ignoreList == null)
                throw new ArgumentNullException("ignoreList");

            ignoreList.Clear();
            ignoreList.Ignore("*.intellisense.js");
            ignoreList.Ignore("*-vsdoc.js");
            ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
        }
示例#8
0
        private static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
        {
            if (ignoreList == null)
            {
                throw new ArgumentNullException("BundleConfig ignore list.");
            }

            ignoreList.Ignore("*.intellisense.js");
            ignoreList.Ignore("*-vsdoc.js");
            //ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
        }
示例#9
0
        private void buttonCustomListLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Title = "Eagle - Open custom list...";
            dialog.Filter = "Eagle Custom List | *.ecl";
            DialogResult result = dialog.ShowDialog(this);

            if (result != DialogResult.OK) return;

            IgnoreList list = new IgnoreList(dialog.FileName);
            string listName = list.Name;

            ListViewItem item = new ListViewItem(list.Name);
            item.SubItems.Add(list.Path);
            listView1.Items.Add(item);
        }
示例#10
0
        private void buttonCustomListNew_Click(object sender, EventArgs e)
        {
            // Get name of destination file
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Title = "Eagle - Save new custom list as...";
            dialog.Filter = "Eagle Custom List | *.ecl";
            var result = dialog.ShowDialog(this);
            if (result != DialogResult.OK) return;
            string filePath = dialog.FileName;
            string fileName = Path.GetFileNameWithoutExtension(filePath);

            // List existing list names
            var existingListNames = new List<string>();
            foreach (ListViewItem item in listView1.Items)
            {
                existingListNames.Add(item.Text);
            }

            // Create unique list name
            int counter = 1;
            string suffix = "";
            while (existingListNames.Contains(fileName + suffix))
            {
                suffix = String.Format(" ({0})", counter++);
            }
            string newListName = fileName + suffix;

            // Create actual IgnoreList
            IgnoreList list = new IgnoreList();
            list.Name = newListName;
            list.SaveAs(filePath);

            // Update list view
            ListViewItem newItem = new ListViewItem(newListName);
            newItem.SubItems.Add(filePath);
            listView1.Items.Add(newItem);

            dialog.Dispose();
        }
示例#11
0
 /// <summary>
 /// Adds the given text to the ignore list so that that warning isn't shown.
 /// </summary>
 /// <param name="text">The text to add to the ignore list</param>
 private void AddToIngoreList(string text)
 {
     // Add it to the ignore list and remove it from being warned right now if it's there.
     IgnoreList.Add(text);
     StopWarning(text);
 }
示例#12
0
        /*-----------------------------------------------------------------------------------------*/
        /* Background worker                                                                       */
        /*-----------------------------------------------------------------------------------------*/
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            OxmlDocument doc = new OxmlDocument(this.GetOXML());
            Scope scope = new Scope(Properties.Settings.Default.ScopeSize);
            scope.MinimumTokenLength = Properties.Settings.Default.MinimumTokenLength;

            doc.PurgeShading();
            doc.PurgeBookmarks();

            // Load ignore list

            if (!String.IsNullOrEmpty(_ignoreListName))
            {
                IgnoreList IgnoreList = new IgnoreList(GetListPath(_ignoreListName));
                scope.IgnoreWords(IgnoreList.LoadWords(_language));
            }

            // Analyse document

            int blockCount = 0;
            float numberOfBlocks = (float)doc.GetNumberOfBlocks();
            var block = doc.GetNextOxmlBlock();

            while (block != null)
            {
                var tokens = block.GenerateOxmlTokens();
                foreach (var token in tokens)
                {
                    scope.FeedToken(token);
                }
                block = doc.GetNextOxmlBlock();

                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }

                int progress = (int)(++blockCount / numberOfBlocks * 100);
                worker.ReportProgress(progress);
            }

            // Add bookmarks to document

            var conflicts = scope.GetConflicts();
            foreach (var root in conflicts.Keys)
            {
                foreach (var conflict in conflicts[root])
                {
                    foreach (var token in conflict)
                    {
                        Debug.WriteLine(String.Format("Adding bookmark {0} for root '{1}' with text '{2}' and range {3}",
                            token.BookmarkName, token.Root, token.Text, token.Range.ToString()));
                        doc.BookmarkRange(token.Range, token.BookmarkName);
                    }
                }
            }

            // Update OXML only if it is valid

            string oxml = doc.ToOxml();

            if (oxml != null)
            {
                this._conflicts = conflicts;
                this.SetOXML(doc.ToOxml());
            }
            else
            {
                MessageBox.Show("An error occured while processing this document.", "Eagle Add-In");
            }
        }
示例#13
0
        /// <summary>
        /// Filters an item from the collection view. Ignores items in the IgnoreList
        /// </summary>
        /// <param name="o">Current Item</param>
        /// <returns>false if the item is in the list, otherwise true</returns>
        private bool Filter(object o)
        {
            Process p = o as Process;

            return(IgnoreList != null ? !IgnoreList.Contains(p.ProcessName) : true);
        }
 /// <summary>
 /// Clears to user dictionary.
 /// </summary>
 public static void ClearUserDictionary()
 {
     UserDictionary = null;
     UserDictionaryWords.Clear();
     IgnoreList.Clear();
 }
        /// <summary>
        /// Loops the given text through spell check <see cref="ISpellCheck.RunSpellCheck"/> interface
        /// method implementation amd returns the user given corrections for the given.
        /// </summary>
        /// <param name="spellCheck">A class instance which implements the <see cref="ISpellCheck"/> interface.</param>
        /// <param name="text">The text to be spell-checked by the user.</param>
        /// <param name="nullOnClose">A value indicating whether to return null if the spell checking was not completed by a user.</param>
        /// <returns>A list of corrections made to the text spell-checked by user.</returns>
        public List <SpellingCorrection> RunSpellCheckInterface(ISpellCheck spellCheck, string text, bool nullOnClose)
        {
            ChecksDoneOnPreviousRun = false;
            var result = new List <SpellingCorrection>(); // create the result instance..

            // attach the methods to the interface-implementing class..
            spellCheck.AddIgnoreWordAction    = AddIgnoreWord;
            spellCheck.AddUserDictionaryWord  = AddUserDictionaryWord;
            spellCheck.RequestWordSuggestion  = SuggestWords;
            spellCheck.CanAddToUserDictionary = CanAddToUserDictionary;
            spellCheck.CanAddToUserIgnoreList = CanAddToUserIgnoreList;

            // run the spell checking for the text..
            var missSpelledWords = SpellCheckFast(text);

            // a value indicating whether the spell checking was created successfully..
            var interrupted = false;

            // ReSharper disable once ForCanBeConvertedToForeach, the collection will change..
            for (int i = 0; i < missSpelledWords.Count; i++)
            {
                // the misspelled word..
                var word = missSpelledWords[i];

                // if the user's personal ignore list contains the word, the skip it..
                if (IgnoreList.Contains(word.Word))
                {
                    continue;
                }

                // check if the word is set to be replaced with the same word at all times..
                var replaceAll = missSpelledWords.FirstOrDefault(f => f.ReplaceAll && f.Word ==
                                                                 word.Word && f.CorrectedWord != null);

                if (replaceAll != null)
                {
                    word.ReplaceAll = true; // set the replace all flag to true..

                    // multiply the replace all to the result for easier implementation..
                    result.Add(new SpellingCorrection
                    {
                        Word          = word.Word,
                        CorrectedWord = replaceAll.CorrectedWord,
                        StartLocation = word.StartLocation,
                        EndLocation   = word.StartLocation + word.Length,
                        ReplaceAll    = word.ReplaceAll,
                    });

                    // clone the found instance of this replace all word..
                    var newWord = replaceAll.Clone();
                    newWord.StartLocation = word.StartLocation;       // change the locations..
                    newWord.EndLocation   = word.EndLocation;
                    newWord.CorrectedWord = replaceAll.CorrectedWord; // set the word correction..

                    // raise the event in case the the spell checking is done in real-time..
                    SpellCheckLocationChanged?.Invoke(this, new SpellCheckLocationChangeEventArgs {
                        SpellingError = newWord, AfterSpellCheck = true
                    });
                    continue; // this case there is no need to go on further..
                }

                // the ignore all case..
                if (missSpelledWords.Any(f => f.IgnoreAll && f.Word == word.Word))
                {
                    // ..the user has made choice to ignore all instances of this misspelled word..
                    continue;
                }

                // raise the event in case the the spell checking is done in real-time so
                // that the whatever-GUI can mark the word before the user makes a choice
                // how to handle the word..
                SpellCheckLocationChanged?.Invoke(this, new SpellCheckLocationChangeEventArgs {
                    SpellingError = word, AfterSpellCheck = false
                });

                // call the ISpellCheck implementation instance to choose the action for a
                // new misspelled word..
                ChecksDoneOnPreviousRun = true;
                if (!spellCheck.RunSpellCheck(word, SuggestWords(word.Word), i + 1, missSpelledWords.Count))
                {
                    // set the interrupted flag to true so the result of this
                    // method can be set accordingly and break the lood..
                    interrupted = true;
                    break;
                }

                // if the word is supposed to be ignored or to be ignored at all times
                // the loop doesn't need to continue any further..
                if (word.IgnoreAll || word.Ignore)
                {
                    continue;
                }

                // if for some reason the corrected word would be null
                // the loop doesn't need to continue any further..
                if (word.CorrectedWord == null)
                {
                    continue;
                }

                // raise the event in case the the spell checking is done in real-time so
                // the corrected word can be applied to the text..
                SpellCheckLocationChanged?.Invoke(this, new SpellCheckLocationChangeEventArgs {
                    SpellingError = word, AfterSpellCheck = true
                });

                // add the corrected word to the result..
                result.Add(new SpellingCorrection
                {
                    Word          = word.Word,
                    CorrectedWord = word.CorrectedWord,
                    StartLocation = word.StartLocation,
                    EndLocation   = word.StartLocation + word.Length,
                    ReplaceAll    = word.ReplaceAll,
                });
            }

            // if the spell checking was interrupted and
            // a null result was requested on interruption, return null..
            if (interrupted && nullOnClose)
            {
                return(null);
            }

            // order the result backwards..
            result =
                result.OrderByDescending(f => f.StartLocation).
                ThenByDescending(f => f.Length).ToList();

            // return the result..
            return(result);
        }
示例#16
0
        public void Load_Rules_From_File()
        {
            var ignoreList = new IgnoreList(_basePath + @"\loadfromfile.gitignore");

            Assert.IsTrue(ignoreList.Rules.Count == 1);
        }
示例#17
0
 public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
 {
     ignoreList.Ignore("*-vsdoc.js");
     ignoreList.Ignore("*.intellisense.js");
     ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
 }
示例#18
0
 public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
 {
     ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
     ignoreList.Ignore("*.debug.css", OptimizationMode.WhenDisabled);
 }
示例#19
0
        private void FindMissingFiles()
        {
            // unhook event handlers to reduce risk of memory leaks
            foreach (MissingErrorTask task in _errorListProvider.Tasks)
            {
                task.Navigate -= SelectParentProjectInSolution;
                task.Navigate -= NewErrorOnNavigate;
            }

            _errorListProvider.Tasks.Clear();

            var projects = _dte.AllProjects();

            var solutionDirectory = Path.GetDirectoryName(_dte.Solution.FullName);

            var        gitIgnoreFile = Path.Combine(solutionDirectory, ".gitignore");
            IgnoreList gitignores    = null;

            if (Options.UseGitIgnore && File.Exists(gitIgnoreFile))
            {
                gitignores = new IgnoreList(gitIgnoreFile);
            }

            var filters = new List <Regex>();

            if (!string.IsNullOrEmpty(Options.IgnorePhysicalFiles))
            {
                filters.AddRange(Options.IgnorePhysicalFiles.Split(new[] { "\r\n" },
                                                                   StringSplitOptions.RemoveEmptyEntries).Select(p => FindFilesPatternToRegex.Convert(p.Trim())));
            }

            foreach (Project proj in projects)
            {
                Debug.WriteLine(proj.Name);

                IDictionary <string, string> dict = new Dictionary <string, string>();
                dict.Add("Configuration", proj.ConfigurationManager.ActiveConfiguration.ConfigurationName);
                using (var projectCollection = new ProjectCollection(dict))
                {
                    var buildProject = projectCollection.LoadProject(proj.FullName);

                    var physicalFiles          = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                    var logicalFiles           = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                    var physicalFileProjectMap = new Dictionary <string, string>();

                    NavigateProjectItems(proj.ProjectItems, buildProject, physicalFiles, logicalFiles,
                                         new HashSet <string>(), physicalFileProjectMap);

                    if (Options.NotIncludedFiles)
                    {
                        var errorCategory = Options.MessageLevel;

                        physicalFiles.ExceptWith(logicalFiles);

                        foreach (var file in physicalFiles)
                        {
                            Debug.WriteLine($"Physical file: {file}");

                            if (filters.Any(f => f.IsMatch(file)) || (gitignores != null && gitignores.IsIgnored(file, false)))
                            {
                                Debug.WriteLine("\tIgnored by filter");
                                continue;
                            }

                            IVsHierarchy hierarchyItem;
                            string       physicalFileProject = physicalFileProjectMap[file];
                            _solution.GetProjectOfUniqueName(physicalFileProject, out hierarchyItem);

                            var newError = new MissingErrorTask()
                            {
                                ErrorCategory = errorCategory,
                                Category      = TaskCategory.BuildCompile,
                                Text          = "File on disk is not included in project",
                                Code          = Constants.FileOnDiskNotInProject,
                                Document      = file,
                                HierarchyItem = hierarchyItem,
                                ProjectPath   = physicalFileProject,
                            };

                            newError.Navigate += SelectParentProjectInSolution;
                            Debug.WriteLine("\t\t** Missing");

                            _errorListProvider.Tasks.Add(newError);
                        }
                    }
                }
            }

            if (_errorListProvider.Tasks.Count > 0)
            {
                _errorListProvider.Show();

                if (Options.FailBuildOnError && Options.Timing == RunWhen.BeforeBuild)
                {
                    _dte.ExecuteCommand("Build.Cancel");
                }
            }
        }
示例#20
0
            public userConextMenu(ChatMessage parent) : base()
            {
                this.Items.Add(new MenuItem()
                {
                    Header = "Open profile"
                });

                if (!FriendList.Exists(parent.Nickname))
                {
                    this.Items.Add(new MenuItem()
                    {
                        Header = "Add to friend list"
                    });
                    ((MenuItem)Items[1]).Click += (o, e) =>
                    {
                        App.FriendList.Add(parent.Nickname);

                        //osu_chat.MainWindow.friends.Add(await osu_chat.MainWindow.GetChatUser(parent.Nickname));
                    };
                }
                else
                {
                    this.Items.Add(new MenuItem()
                    {
                        Header = "Remove from friend list"
                    });
                    ((MenuItem)Items[1]).Click += (o, e) =>
                    {
                        App.FriendList.Remove(parent.Nickname);

                        //osu_chat.MainWindow.friends.Remove(osu_chat.MainWindow.friends.Where(u => u.Nickname == parent.Nickname).First());
                    };
                }

                if (!IgnoreList.Exists(parent.Nickname))
                {
                    this.Items.Add(new MenuItem()
                    {
                        Header = "Add to ignore list"
                    });
                    ((MenuItem)Items[2]).Click += (o, e) =>
                    {
                        IgnoreList.Add(parent.Nickname);

                        //osu_chat.MainWindow.ignoredUser.Add(await osu_chat.MainWindow.GetChatUser(parent.Nickname));
                    };
                }
                else
                {
                    this.Items.Add(new MenuItem()
                    {
                        Header = "Remove from ignore list"
                    });
                    ((MenuItem)Items[2]).Click += (o, e) =>
                    {
                        IgnoreList.Remove(parent.Nickname);
                    };
                }


                ((MenuItem)Items[0]).Click += async(o, e) =>
                {
                    // zameniti na user id
                    Process.Start(string.Format("http://osu.ppy.sh/u/{0}", (await Osu.Api.GetUserAsync(ApiKey, parent.Nickname)).UserId));
                };
            }
示例#21
0
        public static void CopyWithIgnores(DirectoryInfo source, DirectoryInfo target, IgnoreList ignores)
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (target is null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            if (ignores is null)
            {
                throw new ArgumentNullException(nameof(ignores));
            }

            foreach (var dir in source.GetDirectories().Where(d => !ignores.IsIgnored(d)))
            {
                CopyWithIgnores(dir, target.CreateSubdirectory(dir.Name), ignores);
            }

            foreach (var file in source.GetFiles().Where(f => !ignores.IsIgnored(f)))
            {
                file.CopyTo(Path.Combine(target.FullName, file.Name));
            }
        }
示例#22
0
 public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
 {
     ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
     ignoreList.Ignore("*.debug.css", OptimizationMode.WhenDisabled);
 }
示例#23
0
 public List <PropertyInfo> ExcludeProperties(Type x)
 {
     return(IgnoreList.ContainsKey(x) ? IgnoreList[x] : new List <PropertyInfo>());
 }
示例#24
0
 public void ClearIgnoreList()
 {
     IgnoreList.Clear();
 }
示例#25
0
 /// <summary>
 /// Checks to see if a user is in the ignore list.
 /// </summary>
 /// <param name="ident">The IRC identifier of the user.</param>
 /// <returns></returns>
 public bool IsIgnored(string ident) => IgnoreList.Contains(ident);
示例#26
0
        public static void OnScriptError(ScriptCore.ScriptProxy proxy, Exception exception)
        {
            try
            {
                using (TestSpan span = new TestSpan(TimeSpanLogger.Bin, "OnScriptError", DebuggingLevel))
                {
                    bool fullReset = true;

                    bool record = !IgnoreList.IsIgnored(exception, out fullReset);

                    IScriptLogic target = null;
                    if (proxy != null)
                    {
                        target = proxy.Target;
                    }

                    StringBuilder noticeText = new StringBuilder();
                    StringBuilder logText    = new StringBuilder();

                    SimUpdate update = target as SimUpdate;
                    if (update != null)
                    {
                        target = update.mSim;
                    }
                    else
                    {
                        AutonomyManager autonomy = target as AutonomyManager;
                        if (autonomy != null)
                        {
                            target = SearchForAutonomy(exception.StackTrace);
                        }
                        else
                        {
                            Services services = target as Services;
                            if (services != null)
                            {
                                target = SearchForAssignedSim(exception.StackTrace);
                            }
                        }
                    }

                    SimDescription targetSim = SearchForSim(exception.StackTrace);
                    if (targetSim != null)
                    {
                        new FixInvisibleTask(targetSim).AddToSimulator();
                    }

                    IGameObject obj = null;

                    if (targetSim != null)
                    {
                        obj = ScriptCoreLogger.Convert(targetSim, noticeText, logText);
                    }
                    else
                    {
                        obj = ScriptCoreLogger.Convert(target, noticeText, logText);
                        if (obj == null)
                        {
                            obj = target as IGameObject;
                        }
                    }

                    ObjectGuid id       = ObjectGuid.InvalidObjectGuid;
                    bool       moonDial = false;
                    if (obj != null)
                    {
                        id = obj.ObjectId;

                        moonDial = obj.GetType() == typeof(Sims3.Gameplay.Objects.Decorations.MoonDial);

                        if (moonDial)
                        {
                            record = false;
                        }
                    }

                    if (record)
                    {
                        ScriptCoreLogger.Append(noticeText, logText, id, ObjectGuid.InvalidObjectGuid, exception, sAlreadyCaught);
                    }

                    /* do not use else if here */
                    if ((proxy != null) && (proxy.Target is RoleManagerTask))
                    {
                        new CheckRoleManagerTask().Perform(proxy.Target as RoleManagerTask, true);
                    }

                    Sim simObj = obj as Sim;
                    if (simObj != null)
                    {
                        try
                        {
                            if (simObj.Household == null)
                            {
                                fullReset = true;
                            }

                            if ((!fullReset) && (proxy != null))
                            {
                                proxy.OnReset();
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(proxy.Target, null, "PartialReset", e);
                            fullReset = true;
                        }

                        if (fullReset)
                        {
                            if (update != null)
                            {
                                try
                                {
                                    Simulator.DestroyObject(update.Proxy.ObjectId);
                                }
                                catch
                                { }
                            }

                            new ResetSimTask(simObj);
                            return;
                        }
                    }
                    else if (proxy != null && !moonDial)
                    {
                        proxy.OnReset();
                    }
                }
            }
            catch (Exception e)
            {
                Exception(proxy.Target, e);
            }
        }
 /// <summary>
 /// Determines whether the given word can be added to the user ignore word list.
 /// </summary>
 /// <param name="word">The word to check for.</param>
 /// <returns> <c>true</c> if the given word can be added to the user ignore word list; otherwise, <c>false</c>.</returns>
 public bool CanAddToUserIgnoreList(string word)
 {
     return(!IgnoreList.Exists(f =>
                               string.Compare(f, word, StringComparison.Ordinal) == 0));
 }
示例#28
0
        public static void CopyWithIgnores(DirectoryInfo source, DirectoryInfo target, IgnoreList ignores)
        {
            foreach (DirectoryInfo dir in source.GetDirectories().Where(d => !ignores.IsIgnored(d)))
            {
                CopyWithIgnores(dir, target.CreateSubdirectory(dir.Name), ignores);
            }

            foreach (FileInfo file in source.GetFiles().Where(f => !ignores.IsIgnored(f)))
            {
                file.CopyTo(Path.Combine(target.FullName, file.Name));
            }
        }
        /// <summary>
        /// Fetches the miss-spelled words and their locations of the given text using compiled regular expression to match the words.
        /// </summary>
        public List <SpellingError> SpellCheckFast(string text)
        {
            var result = new List <SpellingError>();

            var words = WordBoundaryRegex.Matches(text);


            // initialize a list of failed words to speed up the spell checking..
            List <string> failedWords = new List <string>();

            // initialize a list of passed words to speed up the spell checking..
            List <string> wordOkList = new List <string>();


            for (int i = 0; i < words.Count; i++)
            {
                if (wordOkList.Contains(words[i].Value))
                {
                    // already passed the check..
                    continue;
                }

                // check if the word is already in the list of failed words..
                bool inFailedWordList = failedWords.Contains(words[i].Value);

                if (inFailedWordList)
                {
                    // ..add the location to the result..
                    result.Add(new SpellingError
                    {
                        StartLocation = words[i].Index, EndLocation = words[i].Length + words[i].Index,
                        Word          = words[i].Value,
                    });
                    continue;
                }

                // check the ignore list..
                if (IgnoreList.Exists(f =>
                                      string.Equals(f, words[i].Value, StringComparison.InvariantCultureIgnoreCase)))
                {
                    // flag the word as ok to prevent re-checking the validity..
                    wordOkList.Add(words[i].Value);

                    // the word is valid via user dictionary or user ignore list..
                    continue;
                }

                // validate the possible user dictionary..
                bool userDictionaryOk = UserDictionary?.Check(words[i].Value) ?? false;

                if (userDictionaryOk)
                {
                    // flag the word as ok to prevent re-checking the validity..
                    wordOkList.Add(words[i].Value);

                    // the word is valid via user dictionary or user ignore list..
                    continue;
                }

                // validate the word with the loaded dictionary..
                if (!DictionaryCheck(words[i].Value))
                {
                    // flag the word as invalid to prevent re-checking the validity..
                    failedWords.Add(words[i].Value);

                    // ..add the location to the result..
                    result.Add(new SpellingError
                    {
                        StartLocation = words[i].Index, EndLocation = words[i].Length + words[i].Index,
                        Word          = words[i].Value,
                    });
                }
                else
                {
                    // flag the word as ok to prevent re-checking the validity..
                    wordOkList.Add(words[i].Value);
                }
            }

            return(result);
        }
示例#30
0
        public void Handle_Non_Relative_Path()
        {
            var list = new IgnoreList(new string[] { "ignored/" });

            Assert.IsTrue(list.IsIgnored("/ignored/test/test.txt", false));
        }
示例#31
0
文件: Client.cs 项目: uwat79/OCTGN
        public void UnignoreUser(User user)
        {
            IgnoreList.RemoveAll(x => x.Val == user.JidUser);

            PrivacyManager.UpdateList("ignore", IgnoreList.ToArray(), OnIgnorelistUpdated, null);
        }
示例#32
0
 public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
 {
     if(ignoreList == null) {
     throw new ArgumentNullException("ignoreList");
       }
 }
        private async void btnCreateFile_Click(object sender, RoutedEventArgs e)
        {
            DirectoryInfo       wot    = new DirectoryInfo(txtGameFolder.Text);
            string              output = txtOutputFile.Text;
            RootDirectoryEntity root   = new RootDirectoryEntity(Helpers.GetGameVersion(txtGameFolder.Text));
            HashProvider        sha1   = new SHA1HashProvider();

            btnCreateFile.IsEnabled = false;
            btnCreateFile.Content   = "Creating...";
            await Task.Run(() => GameDirectoryParser.Parse(wot, root, wot.FullName.Length, sha1, IgnoreList.FromEnumerable(File.ReadAllLines("ignored.txt")), null));

            await Task.Run(() => new RootDirectoryEntityIO().Serialize(root, output));

            btnCreateFile.Content   = "Create";
            btnCreateFile.IsEnabled = true;
        }
示例#34
0
 internal void IgnoreListNameChanged(string filePath, string newName)
 {
     IgnoreList ignoreList = new IgnoreList(filePath);
     ignoreList.Name = newName;
     ignoreList.Save();
 }