/// <summary> /// Loads up all of the options and applys them to the application. NB this takes a stream and loads from it but does not /// close the stream. It is assumed this is done by the caller. /// </summary> /// <param name="storeStream">Stream containing a serialised MexOptions structure</param> internal static MexOptions LoadFromFile(Stream storeStream) { MexOptions result = new MexOptions(); // Make sure nothing gets missed. result.LoadOptionsDefaults(); //Bilge.Log("About to load MexOptions settings from stream. "); XmlSerializer xmls = new XmlSerializer(typeof(MexOptions)); result = (MexOptions)xmls.Deserialize(storeStream); if ((result.ResetRefreshOnStartup) && (result.NoSecondsForRefreshOnImport > Consts.REFRESHTIME_UNNACCEPTABLE)) { result.NoSecondsForRefreshOnImport = Consts.DEFAULT_UIREFRESHTIME; } //Bilge.Log("Load completed, options now imported"); // Find all of the filter files int i; // loop counter if (!Directory.Exists(result.FilterAndHighlightStoreDirectory)) { //Bilge.Warning("Invalid filter directory found on startup, resetting to current directory"); result.FilterAndHighlightStoreDirectory = Environment.CurrentDirectory; } string[] filenames = Directory.GetFiles(result.FilterAndHighlightStoreDirectory, result.FilterExtension); result.CurrentMexFilterNames = new string[filenames.Length]; for (i = 0; i < filenames.Length; i++) { result.CurrentMexFilterNames[i] = Path.GetFileNameWithoutExtension(filenames[i]); } result.CurrentMexHighlightNames = new string[filenames.Length]; for (i = 0; i < filenames.Length; i++) { result.CurrentMexHighlightNames[i] = Path.GetFileNameWithoutExtension(filenames[i]); } // then create tasks to ensure options are honoured //Bilge.Log("Filters and so on are found, applying options settings to the application"); return(result); }
private MexCore() { //Bilge.Log("MexCore::MexCore - Core being initialised"); EventEntryStoreFactory esf = new EventEntryStoreFactory(); DataManager dm = new DataManager(esf); OriginIdentityStore store = new OriginIdentityStore(); RawEntryParserChain rapc = RawEntryParserChain.CreateChain(RawEntryParserChain.ALL_LINK, store); DataParser dp = new DataParser(store, rapc, dm); ImportManager im = new ImportManager(dp); //Bilge.Log("MexCore::MexCore - Diagnostics being initialised"); Diagnostics = new MexDiagnosticManager(); //Bilge.Log("MexCore::MexCore - about to start Options"); Options = new MexOptions(); //Bilge.Log("MexCore::MexCore - about to start WorkManager"); WorkManager = PrimaryWorkManager.GetPrimaryWorkManager(); //Bilge.Log("MexCore::MexCore - about to start DataStructures"); DataManager = new DataStructureManager(); //Bilge.Log("MexCore::MexCore - about to start IncommingMessageManager"); MessageManager = IncomingMessageManager.Current; //MessageManager.AddFlimFlamCompatibility(im); //Bilge.Log("MexCore::MexCore - about to start ViewManager"); ViewManager = new ViewSupportManager(); //Bilge.Log("MexCore::MexCore - about to start CacheManager"); CacheManager = new CacheSupportManager(); //Bilge.Log("MexCore::MexCore - Starting CoreWorkerThread"); m_coreExecutionThread = new Thread(new ThreadStart(CoreThreadLoop)); m_coreExecutionThread.Name = "MexCoreThread"; //Bilge.Log("MexCore::MexCore - Construction complete"); }
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
private void PopulateFromMe(MexOptions src) { this.AutoLoadHighlightDefaultOnStartup = src.AutoLoadHighlightDefaultOnStartup; this.AutoPurgeApplicationOnMatchingName = src.AutoPurgeApplicationOnMatchingName; this.AutoRefresh = src.AutoRefresh; this.AutoScroll = src.AutoScroll; this.CurrentMexFilterNames = src.CurrentMexFilterNames; this.CurrentMexHighlightNames = src.CurrentMexHighlightNames; this.DisplayInternalMessages = src.DisplayInternalMessages; this.FilterAndHighlightStoreDirectory = src.FilterAndHighlightStoreDirectory; this.FilterFilenameToLoadOnStartup = src.FilterFilenameToLoadOnStartup; this.FilterExtension = src.FilterExtension; this.HighlightDefaultProfileName = src.HighlightDefaultProfileName; this.HighlightExtension = src.HighlightExtension; this.ImportTextFileBehaviour = src.ImportTextFileBehaviour; this.InteractiveNotifications = src.InteractiveNotifications; this.LogNotifications = src.LogNotifications; this.NormalisationLimitMilliseconds = src.NormalisationLimitMilliseconds; this.NormaliseRefreshActive = src.NormaliseRefreshActive; this.PushbackCountDelayLimitForInteractiveJobs = src.PushbackCountDelayLimitForInteractiveJobs; this.RespectFilter = src.RespectFilter; this.SelectingProcessSelectsProcessView = src.SelectingProcessSelectsProcessView; this.AutoSelectFirstProcess = src.AutoSelectFirstProcess; this.ShowGlobalIndexInView = src.ShowGlobalIndexInView; this.StatusBarNotifications = src.StatusBarNotifications; this.SupportCancellationOfRefresh = src.SupportCancellationOfRefresh; this.SupportCancellationRepeatCount = src.SupportCancellationRepeatCount; this.TimedViewRespectsFilter = src.TimedViewRespectsFilter; this.XRefReverseCopyEnabled = src.XRefReverseCopyEnabled; this.XRefMatchingProcessIdsIntoEventEntries = src.XRefMatchingProcessIdsIntoEventEntries; this.XRefAppInitialiseToMain = src.XRefAppInitialiseToMain; this.XRefAssertionsToMain = src.XRefAssertionsToMain; this.XRefErrorsToMain = src.XRefErrorsToMain; this.XRefExceptionsToMain = src.XRefExceptionsToMain; this.XRefLogsToMain = src.XRefLogsToMain; this.XRefMiniLogsToMain = src.XRefMiniLogsToMain; this.XRefResourceMessagesToMain = src.XRefResourceMessagesToMain; this.XRefVerbLogsToMain = src.XRefVerbLogsToMain; this.XRefWarningsToMain = src.XRefWarningsToMain; this.BeautifyDisplayedStrings = src.BeautifyDisplayedStrings; this.IPAddressToBind = src.IPAddressToBind; this.PortAddressToBind = src.PortAddressToBind; this.MatchingNamePurgeAlsoClearsPartials = src.MatchingNamePurgeAlsoClearsPartials; this.ThreadDisplayOption = src.ThreadDisplayOption; this.AttemptToFixMismatchedTimingEntries = src.AttemptToFixMismatchedTimingEntries; this.UseThreadNamingWhereverPossible = src.UseThreadNamingWhereverPossible; this.FilterDefaultSaveClassLocation = src.FilterDefaultSaveClassLocation; this.FilterDefaultSaveLocations = src.FilterDefaultSaveLocations; this.FilterDefaultSaveModules = src.FilterDefaultSaveModules; this.FilterDefaultSaveThreads = src.FilterDefaultSaveThreads; this.CrossProcessViewHighlight = src.CrossProcessViewHighlight; this.EnableBackTrace = src.EnableBackTrace; this.ThreadDisplayOption = src.ThreadDisplayOption; this.NoSecondsForRefreshOnImport = src.NoSecondsForUIUpdate; this.NoSecondsForUIUpdate = src.NoSecondsForUIUpdate; this.ResetRefreshOnStartup = src.ResetRefreshOnStartup; this.RemoveDuplicatesOnImport = src.RemoveDuplicatesOnImport; this.RemoveDuplicatesOnView = src.RemoveDuplicatesOnView; this.NoUserNotificationsToStoreInLog = src.NoUserNotificationsToStoreInLog; this.UsePreferredNameInsteadOfProcessId = src.UsePreferredNameInsteadOfProcessId; }
internal MexOptions(MexOptions mo) { LoadOptionsDefaults(); this.PopulateFromMe(mo); }