Example #1
0
        private static string ParsedEventHTML(ParsedEvent evt)
        {
            var htime = evt.HasTime ? "<b>" + evt.Time + "</b> " : "";

            return(String.Format("<font color={0}>&bull; {1}{2}</font><br>",
                                 evt.Color, htime, evt.Text));
        }
Example #2
0
        // TODO: this should probably better return class instance for the purpose of using its methods, e.g. ToString, but then we lose the FieldMeta descriptions
        public List <ParsedEvent> ParseStream(TcpStream tcpStream, ParseMode parseMode = ParseMode.Root, long startingStreamPosition = 0)
        {
            var events = new List <ParsedEvent>();
            var stream = new MemoryStream();

            lock (tcpStream)
            {
                var position = tcpStream.Position;
                tcpStream.Position = startingStreamPosition;
                tcpStream.CopyTo(stream);
                tcpStream.Position = position;
            }

            _br = new BinaryReader(stream);
            _br.BaseStream.Position = 0;

            while (_br.BaseStream.Position < _br.BaseStream.Length)
            {
                try
                {
                    var positionBeforeRead = _br.BaseStream.Position;

                    var newParsedEvent = new ParsedEvent
                    {
                        Offset    = positionBeforeRead + startingStreamPosition,
                        Sender    = tcpStream.Sender,
                        ParseMode = parseMode
                    };
                    var packetData = ReadEvent(out var opCode, parseMode);

                    if (packetData.Count == 0)
                    {
                        break;
                    }

                    newParsedEvent.OpCode = opCode;
                    newParsedEvent.Length = _br.BaseStream.Position - positionBeforeRead;
                    newParsedEvent.Data   = packetData;
                    newParsedEvent.Time   = tcpStream.PacketAtOffset(startingStreamPosition + _br.BaseStream.Position).Time;

                    events.Add(newParsedEvent);
                }
                catch (Exception e)
                {
                    // Safe exit
                    break;
                }
            }

            _br.Dispose();
            _br = null;

            return(events);
        }
Example #3
0
        public void Visit(ParsedEvent pars)
        {
            // to code explorer
            var parentNode = pars.Type == ParsedEventType.Subscribe ? GetExplorerListNode("Subscribe", CodeExplorerIconType.Subscribe) : (pars.Type == ParsedEventType.Unsubscribe ? GetExplorerListNode("Unsubscribe", CodeExplorerIconType.Unsubscribe) : GetExplorerListNode("Publish", CodeExplorerIconType.Publish));
            var newNode    = CodeItem.Factory.New(pars.Type == ParsedEventType.Subscribe ? CodeExplorerIconType.Subscribe : (pars.Type == ParsedEventType.Unsubscribe ? CodeExplorerIconType.Unsubscribe : CodeExplorerIconType.Publish));

            newNode.DisplayText   = pars.Name;
            newNode.Flags         = pars.Flags;
            newNode.SubText       = null;
            newNode.DocumentOwner = pars.FilePath;
            newNode.GoToLine      = pars.Line;
            newNode.GoToColumn    = pars.Column;
            PushToCodeExplorer(parentNode, newNode);
        }
Example #4
0
            private unsafe void ProcessEvents(int numEvents,
                                              byte **eventPaths,
                                              Span <FSEventStreamEventFlags> eventFlags,
                                              Span <FSEventStreamEventId> eventIds,
                                              FileSystemWatcher watcher)
            {
                // Since renames come in pairs, when we reach the first we need to test for the next one if it is the case. If the next one belongs into the pair,
                // we'll store the event id so when the for-loop comes across it, we'll skip it since it's already been processed as part of the original of the pair.
                int?handledRenameEvents = null;

                for (int i = 0; i < numEvents; i++)
                {
                    using ParsedEvent parsedEvent = ParseEvent(eventPaths[i]);

                    ReadOnlySpan <char> path = parsedEvent.Path;
                    Debug.Assert(path[^ 1] != '/', "Trailing slashes on events is not supported");
Example #5
0
        private void DisplayEvent(ParsedEvent parsedEvent)
        {
            eventsTable.Invoke((MethodInvoker) delegate
            {
                var icon      = parsedEvent.Sender == SenderEnum.Client ? _iconClientSource : _iconServerSource;
                var localTime = parsedEvent.Time.Date.ToLocalTime().ToString("HH:mm:ss.ffffff");

                var rowIndex = eventsTable.Rows.Add(icon, _eventIndex++, localTime, parsedEvent.OpCode, parsedEvent.Length, "");

                eventsTable.Rows[rowIndex].Tag = parsedEvent;

                if (_stickEventsToBottom)
                {
                    eventsTable.FirstDisplayedScrollingRowIndex = eventsTable.RowCount - 1;
                }
            });
        }
Example #6
0
        private void PreviewEvent(ParsedEvent parsedEvent)
        {
            var data = _connectionInfo.GetEventBytes(parsedEvent);

            packetPreview.Invoke((MethodInvoker) delegate
            {
                packetPreview.ByteProvider = new DynamicByteProvider(data);
            });

            if (parsedEvent.ParseMode == ParseMode.Root && _templateParser != null)
            {
                parsedEvent.Data      = new TemplateReader(_templateParser).ParseBuffer(data, ParseMode.Complete);
                parsedEvent.ParseMode = ParseMode.Complete;
            }

            ParentForm.Invoke((MethodInvoker) delegate
            {
                ParentForm.PreviewFlowData(parsedEvent.Data);
            });
        }
Example #7
0
        BuildDayToEventsTable(TreeNodeCollection nodes)
        {
            var dayToEvents = new Dictionary <DateTime, List <ParsedEvent> >();

            Util.EachNode(nodes,
                          delegate(TreeNode node)
            {
                var evt = new ParsedEvent(node.Text);
                if (evt.HasDate)
                {
                    if (dayToEvents[evt.Date] == null)
                    {
                        dayToEvents[evt.Date] = new List <ParsedEvent>();
                    }
                    dayToEvents[evt.Date].Add(evt);
                }
            });

            foreach (var date in dayToEvents.Keys)
            {
                dayToEvents[date].Sort(ParsedEventSorter.Instance);
            }
            return(dayToEvents);
        }
Example #8
0
 public void Visit(ParsedEvent pars)
 {
     AppendEverything(pars);
 }