Пример #1
0
 private void RaiseEvent(LogNode logNode,bool isRootItem)
 {
     if (ItemAdded != null)
     {
         ItemAdded.Invoke(this, new LogNodeEvent(logNode, isRootItem));
     }
 }
Пример #2
0
        public void Consume(IEntryData entryData)
        {
            if (entryData.GetEntryType().FullName == "Whitelog.Interface.LogEntry")
            {
                var titleInfo = (entryData.GetProperties().ElementAt(2).GetValue(entryData) as GenericPackageData);
                int scopeId = (int) (entryData.GetProperties().ElementAt(1).GetValue(entryData));
                if (titleInfo.Type == "Whitelog.Core.OpenLogScopeTitle")
                {
                    int parentScopeId = (int) titleInfo.GetValue(1);
                    var node= new LogNode()
                    {
                        Time = (DateTime) entryData.GetProperties().ElementAt(0).GetValue(entryData),
                        Title = null,
                        Message = titleInfo.GetValue(0).ToString(),
                        Children = new List<LogNode>(),
                    };

                    m_openNodes.Add(scopeId,node);

                    LogNode parentNode;
                    if (m_openNodes.TryGetValue(parentScopeId, out parentNode))
                    {
                        parentNode.Children.Add(node);
                        RaiseEvent(parentNode,false);

                    }
                    else
                    {
                        LogNodes.Add(node);
                        RaiseEvent(node,true);
                    }
                }
                else if (titleInfo.Type == "Whitelog.Core.CloseLogScopeTitle")
                {
                    if (m_openNodes.ContainsKey(scopeId))
                    {
                        LogNode parentNode;
                        if (m_openNodes.TryGetValue(scopeId, out parentNode))
                        {
                            parentNode.Children.Add(new LogNode()
                                                    {
                                                        Message =  "<-",
                                                        Time = (DateTime)entryData.GetProperties().ElementAt(0).GetValue(entryData),
                                                        Title = null,
                                                    });
                            RaiseEvent(parentNode, false);
                        }
                        m_openNodes.Remove(scopeId);
                    }
                }
                else
                {
                    var node = new LogNode()
                               {
                                   Time = (DateTime) entryData.GetProperties().ElementAt(0).GetValue(entryData),
                                   Title = titleInfo.GetValue(1).ToString(),
                                   Message = titleInfo.GetValue(0).ToString(),
                               };
                    LogNode parentNode;
                    if (m_openNodes.TryGetValue(scopeId, out parentNode))
                    {
                        parentNode.Children.Add(node);
                        RaiseEvent(parentNode,false);
                    }
                    else
                    {
                        LogNodes.Add(node);
                        RaiseEvent(node,true);
                    }
                }
            }
        }
Пример #3
0
 public LogNodeEvent(LogNode logNode,bool isRootItem)
 {
     IsRootItem = isRootItem;
     LogNode = logNode;
 }