/// <summary> /// Duplicates the filter provided into this filter, copying all of the filter restrictions, except the index representing /// the filter. /// </summary> /// <param name="vf"></param> internal ViewFilter(ViewFilter vf) { this.BeginFilterUpdate(); this.m_caseSensitive = vf.m_caseSensitive; if (vf.m_excludedLocationsClass != null) { this.m_excludedLocationsClass.AddRange(vf.m_excludedLocationsClass.ToArray()); } if (vf.m_excludedLocationsFull != null) { this.m_excludedLocationsFull.AddRange(vf.m_excludedLocationsFull.ToArray()); } if (vf.m_excludedModules != null) { this.m_excludedModules.AddRange(vf.m_excludedModules.ToArray()); } if (vf.m_excludedThreads != null) { this.m_excludedThreads.AddRange(vf.m_excludedThreads.ToArray()); } this.m_excludeEventsAboveThisIndex = vf.m_excludeEventsAboveThisIndex; this.ExcludeEventsBelowThisIndex = vf.ExcludeEventsBelowThisIndex; if (vf.m_exclusionStrings != null) { this.m_exclusionStrings.AddRange(vf.m_exclusionStrings.ToArray()); } this.m_filterDescription = vf.m_filterDescription; this.m_flagsForInclude = vf.m_flagsForInclude; this.m_inclusionStrings = vf.m_inclusionStrings; this.UseAboveThisFilter = vf.UseAboveThisFilter; this.UseBelowThisFilter = vf.UseBelowThisFilter; this.EndFilterUpdate(); }
internal static void SaveFilterToFile(string filename, ViewFilter thisFilter, bool includeThreads, bool includeModules, bool includeLocations, bool includeClassLocations) { //Bilge.E(); try { if (includeThreads & includeModules & includeLocations & includeClassLocations == false) { //Bilge.VerboseLog("Not all filter data is being persisted, removing filter elements that are not to be stored"); thisFilter = new ViewFilter(thisFilter); if (!includeThreads) { thisFilter.m_excludedThreads = null; } if (!includeModules) { thisFilter.m_excludedModules = null; } if (!includeLocations) { thisFilter.m_excludedLocationsFull = null; } if (!includeClassLocations) { thisFilter.m_excludedLocationsClass = null; } } XmlSerializer xmls = new XmlSerializer(typeof(ViewFilter)); //Bilge.VerboseLog("About to write the persisted filter data out to the disk, using filename " + filename); using (FileStream fs = new FileStream(filename, FileMode.Create)) { xmls.Serialize(fs, thisFilter); fs.Close(); } } finally { //Bilge.X(); } }
internal void ApplyOptionsToApplication(MexOptions newOptions, bool isStartup) { //Bilge.Log("Dispatching notificaiton event of options changed"); MexCore.TheCore.ViewManager.AddUserNotificationMessageByIndex(ViewSupportManager.UserMessages.BackgroundApplyOptionsBegins, ViewSupportManager.UserMessageType.InformationMessage, ""); bool forceResetOfIPListener = false; bool fullRefreshRequired = false; // Some of the options occur during application startup. if (isStartup) { fullRefreshRequired = true; if ((newOptions.FilterFilenameToLoadOnStartup != null) && (newOptions.FilterFilenameToLoadOnStartup.Length > 0) && (File.Exists(newOptions.FilterFilenameToLoadOnStartup))) { ViewFilter vf = ViewFilter.LoadFilterFromFile(newOptions.FilterFilenameToLoadOnStartup); MexCore.TheCore.ViewManager.CurrentFilter = vf; } if ((newOptions.HighlightDefaultProfileName != null) && (newOptions.HighlightDefaultProfileName.Length > 0)) { string[] matchedHighlights = newOptions.HighlightDefaultProfileName.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); XmlSerializer xmls = new XmlSerializer(typeof(AHighlightRequest)); foreach (string s in matchedHighlights) { string path = Path.Combine(MexCore.TheCore.Options.FilterAndHighlightStoreDirectory, s + MexCore.TheCore.Options.HighlightExtension); if (File.Exists(path)) { using (FileStream fs = new FileStream(path, FileMode.Open)) { AHighlightRequest loaded = (AHighlightRequest)xmls.Deserialize(fs); fs.Close(); MexCore.TheCore.ViewManager.CurrentHighlightOptions.HighlightRequests.Add(loaded); MexCore.TheCore.ViewManager.ReapplyHighlight(); } } } } } #region check the option differences and decide if a refresh or IP reset required // This is not thread safe but instead we suspend the other thread that could be accessing it if ((newOptions.IPAddressToBind != MexCore.TheCore.Options.IPAddressToBind) || (newOptions.PortAddressToBind != MexCore.TheCore.Options.PortAddressToBind)) { forceResetOfIPListener = true; } if ((newOptions.BeautifyDisplayedStrings != MexCore.TheCore.Options.BeautifyDisplayedStrings)) { fullRefreshRequired = true; } if (newOptions.DisplayInternalMessages != MexCore.TheCore.Options.DisplayInternalMessages) { fullRefreshRequired = true; } if (newOptions.UsePreferredNameInsteadOfProcessId != MexCore.TheCore.Options.UsePreferredNameInsteadOfProcessId) { fullRefreshRequired = true; } #endregion MexCore.TheCore.Options = newOptions; if (forceResetOfIPListener) { MexCore.TheCore.WorkManager.AddJob(new Job_ChangeTCPGathererState(false)); MexCore.TheCore.WorkManager.AddJob(new Job_ChangeTCPGathererState(true)); } if (fullRefreshRequired) { MexCore.TheCore.WorkManager.AddJob(new Job_NotifyRefreshRequired()); } // When the threads come back online they should process any of the changes that are requested. } // End MexOptions.ApplyOptionstoApplication