Ejemplo n.º 1
0
        protected void AddEvent(XElement element, Guid id)
        {
            foreach (XElement child in element.Elements())
            {
                EventOffset eventOffset = this.eventOffsetParser.ParseEventData(element);

                if (eventOffset != null)
                {
                    this.currentEventOffset = TimeSpan.FromSeconds(eventOffset.Offset);
                    this.Items.ForEach(ed => ed.Time.Add(this.currentEventOffset));
                    this.logEntries[id].Offset = this.currentEventOffset;
                }
                else
                {
                    EventData eventData = this.eventDataParser.ParseEventData(child);

                    this.logEntries[id].DataEntries.Add(eventData);
                    this.InvokeEventDataAdded(eventData);
                }
            }
        }
Ejemplo n.º 2
0
        protected void RemoveEvent(XElement element, Guid targetId)
        {
            foreach (var child in element.Elements())
            {
                EventOffset eventOffset = this.eventOffsetParser.ParseEventData(child);

                if (eventOffset != null)
                {
                    var offset = TimeSpan.FromSeconds(eventOffset.Offset);
                    this.Items.ForEach(ed => ed.Time.Add(offset));
                    this.currentEventOffset = TimeSpan.Zero;
                }
            }

            int initialCount = 0;
            int finalCount   = 0;

            this.logEntries.Values.ForEach(edl => initialCount += edl.DataEntries.Count);

            if (targetId != Guid.Empty)
            {
                if (this.logEntries.ContainsKey(targetId))
                {
                    if (this.logEntries[targetId].Offset != TimeSpan.Zero)
                    {
                        this.Items.ForEach(ed => ed.Time.Subtract(this.logEntries[targetId].Offset));
                        this.currentEventOffset = TimeSpan.Zero;
                    }
                    else
                    {
                        foreach (var entry in this.logEntries[targetId].DataEntries.ToList())
                        {
                            this.logEntries[targetId].DataEntries.Remove(entry);
                            this.InvokeEventDataRemoved(entry);
                        }
                    }
                }

                this.logEntries.Values.ForEach(edl => finalCount += edl.DataEntries.Count);
                if (initialCount == finalCount)
                {
                    foreach (LogEntry logEntry in this.logEntries.Values)
                    {
                        if (logEntry.TargetId == targetId && this.logEntries.ContainsKey(targetId))
                        {
                            if (this.logEntries[targetId].Offset != TimeSpan.Zero)
                            {
                                this.Items.ForEach(ed => ed.Time.Subtract(this.logEntries[targetId].Offset));
                                this.currentEventOffset = TimeSpan.Zero;
                            }
                            else
                            {
                                foreach (var entry in this.logEntries[targetId].DataEntries.ToList())
                                {
                                    this.logEntries[targetId].DataEntries.Remove(entry);
                                    this.InvokeEventDataRemoved(entry);
                                }
                            }
                        }
                    }
                }
            }
        }