/// <summary> /// Create messageReader accroding to file extension /// </summary> /// <param name="CaptureFile">Capture file path</param> /// <returns></returns> IMessageReader CreateMessageReader(string CaptureFile) { IMessageReader reader = null; //Create and Initialize Message Meta data loader catalog MessageMetadataLoaderCatalog messageMetadataLoaderCatalog = new MessageMetadataLoaderCatalog(); messageMetadataLoaderCatalog.Initialize(monitor.Settings.ExtensionLoadPath); if (PersistUtils.IsUnparsedProjectFile(CaptureFile)) { //If capture file is an uncompressed project file reader = FileMessageReader.CreateReaderFromProjectFile(CaptureFile, messageMetadataLoaderCatalog); } else if (PersistUtils.IsCompressedUnparsedProjectFile(CaptureFile) || PersistUtils.IsCompressedProjectFile(CaptureFile)) { //If capture file is a compressed project file reader = FileMessageReader.CreateReaderFromCompressedFile(CaptureFile, messageMetadataLoaderCatalog); } else { //other file type, such as netmon capture file FileReaderCatalog fileReaderCatalog = new FileReaderCatalog(); fileReaderCatalog.Initialize(monitor.Settings.ExtensionLoadPath); IFileLoader fileLoader = fileReaderCatalog.GetRegisteredFileLoaders(CaptureFile).First(); reader = fileLoader.OpenFile(CaptureFile, fileLoader.CreateDefaultConfig(null)); } return(reader); }
/// <summary> /// Save captured message into a file. /// </summary> /// <param name="filepath">File path to save captured messages</param> /// <param name="selectedOnly">Indicate save only selected messages or all messages</param> /// <returns></returns> public virtual bool SaveCapturedMessages(string filepath) { // Create and initialize a FileWriterCatalog FileWriterCatalog writerCatalog = new FileWriterCatalog(); writerCatalog.Initialize(monitor.Settings.ExtensionLoadPath); if (PersistUtils.IsPersistTypeSupported(writerCatalog, filepath)) { MessageIds capturedMessageids = CapturedMessageIds; // Save All messages if (capturedMessageids.Count > 0) { PersistUtils.Persist(captureJournal, writerCatalog, filepath, capturedMessageids); return(true); } } return(false); }