private void ResolveProperties(DebugTreeItem debugLogItem, object dataItem)
 {
     if (dataItem == null)
     {
         return;
     }
     PropertyInfo[] properties = dataItem.GetType().GetProperties();
     for (int i = 0; i < properties.Length; i++)
     {
         PropertyInfo propertyInfo = properties[i];
         try
         {
             DebugTreeItem debugLogItem2 = new DebugTreeItem
             {
                 Name        = propertyInfo.Name,
                 Value       = this.ResolveValueOfProperty(propertyInfo, dataItem),
                 DateTime    = null,
                 LogCategory = null
             };
             this.CreateChildNode(debugLogItem, debugLogItem2, null);
             if (!(propertyInfo.PropertyType == typeof(DateTime)) && !(propertyInfo.PropertyType == typeof(string)) && !(propertyInfo.PropertyType == typeof(char)) && !(propertyInfo.PropertyType == typeof(int)) && !(propertyInfo.PropertyType == typeof(short)) && !(propertyInfo.PropertyType == typeof(bool)))
             {
                 if (propertyInfo.GetIndexParameters().Length == 0)
                 {
                     this.ResolveProperties(debugLogItem2, propertyInfo.GetValue(dataItem, null));
                 }
             }
         }
         catch (Exception ex)
         {
             HelperFunctions.DebugLine(string.Format("{0}::{1} FAILED RESOLVE PROPERTIES {2}", base.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message));
         }
     }
 }
 public DebugTreeModel()
 {
     this._mLogData     = new ObservableCollection <DebugTreeItem>();
     this._exeptionNode = new DebugTreeItem
     {
         Name     = "Exception",
         NodeName = "Exception"
     };
     this._systemInfoNode = new DebugTreeItem
     {
         Name     = "SystemInfo",
         NodeName = "SystemInfo"
     };
     this._sessionsNode = new DebugTreeItem
     {
         Name     = "Sessions",
         NodeName = "Sessions"
     };
     this._mLogData.Add(this._exeptionNode);
     this._mLogData.Add(this._systemInfoNode);
     this._mLogData.Add(this._sessionsNode);
     this._mImportantVerbs = new List <string>
     {
         "err",
         "warning:",
         "sigterm",
         "exiting",
         "restart",
         "timeout",
         "completed",
         "link remote",
         "failed"
     };
 }
 public DebugTreeItem CreateNewSession(int sessionIndex = 0)
 {
     if (sessionIndex == 0)
     {
         sessionIndex = this._sessionsNode.Childs.Count + 1;
     }
     this._currentSession = new DebugTreeItem
     {
         Name     = string.Format("Session{0}", sessionIndex),
         NodeName = string.Format("Session{0}", sessionIndex)
     };
     this._mServiceNode = new DebugTreeItem
     {
         Name     = "Service",
         NodeName = "Service"
     };
     this._mGuiNode = new DebugTreeItem
     {
         Name     = "GUI",
         NodeName = "GUI"
     };
     this._mOpenVpnNode = new DebugTreeItem
     {
         Name     = "OpenVPN",
         NodeName = "OpenVPN"
     };
     this._currentSession.Childs.Add(this._mGuiNode);
     this._currentSession.Childs.Add(this._mServiceNode);
     this._currentSession.Childs.Add(this._mOpenVpnNode);
     this.CreateChildNode(this._sessionsNode, this._currentSession, null);
     return(this._currentSession);
 }
 private void CreateChildNode(DebugTreeItem parent, DebugTreeItem debugLogItem, object dataItem = null)
 {
     if (debugLogItem != null && parent != null)
     {
         ObservableCollection <DebugTreeItem> childs = parent.Childs;
         lock (childs)
         {
             parent.Childs.Add(debugLogItem);
         }
         if (dataItem != null)
         {
             this.ResolveProperties(debugLogItem, dataItem);
         }
         return;
     }
 }
 private void ResolveSession(McSessionLogItems item)
 {
     foreach (McSessionLogItem arg_21_0 in item.get_Sessions())
     {
         this.CreateNewSession(0);
         foreach (KeyValuePair <string, List <McSerializedItem> > current in arg_21_0.get_EventTypes())
         {
             using (List <McSerializedItem> .Enumerator enumerator3 = current.Value.GetEnumerator())
             {
                 while (enumerator3.MoveNext())
                 {
                     McBaseLogItem mcBaseLogItem = (McBaseLogItem)enumerator3.Current.GetItem();
                     DebugTreeItem debugTreeItem = new DebugTreeItem
                     {
                         Name        = mcBaseLogItem.get_Name(),
                         Value       = mcBaseLogItem.ToString(),
                         DateTime    = mcBaseLogItem.get_DateTime().ToString(CultureInfo.InvariantCulture),
                         LogCategory = mcBaseLogItem.get_DebugLevel().ToString(),
                         Item        = mcBaseLogItem
                     };
                     if (mcBaseLogItem.get_Name().StartsWith("OpenVPNLog"))
                     {
                         debugTreeItem.NodeName = "OpenVPNLog";
                         string debugData = ((McOpenVpnLogItem)mcBaseLogItem).get_DebugData();
                         debugTreeItem.Highlight = this.ContainsImportantVerb(debugData);
                         this.CreateChildNode(this._mOpenVpnNode, debugTreeItem, mcBaseLogItem);
                     }
                     if (mcBaseLogItem.get_Name().StartsWith("Service"))
                     {
                         debugTreeItem.NodeName = "Service";
                         this.CreateChildNode(this._mServiceNode, debugTreeItem, mcBaseLogItem);
                     }
                     if (mcBaseLogItem.get_Name().StartsWith("Gui"))
                     {
                         debugTreeItem.NodeName = "Gui";
                         this.CreateChildNode(this._mGuiNode, debugTreeItem, mcBaseLogItem);
                     }
                 }
             }
         }
     }
 }
        public void DeserializeDebugData(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                return;
            }
            McBaseLogItem mcBaseLogItem = (McBaseLogItem)JsonConvert.DeserializeObject <McSerializedItem>(data).GetItem();

            if (mcBaseLogItem.get_Name() == "Init")
            {
                return;
            }
            DebugTreeItem debugTreeItem = new DebugTreeItem
            {
                Name        = mcBaseLogItem.get_Name(),
                Value       = mcBaseLogItem.ToString(),
                DateTime    = mcBaseLogItem.get_DateTime().ToString(CultureInfo.InvariantCulture),
                LogCategory = mcBaseLogItem.get_DebugLevel().ToString(),
                Item        = mcBaseLogItem
            };

            if (mcBaseLogItem.get_Name().StartsWith("Sessions"))
            {
                this.ResolveSession((McSessionLogItems)mcBaseLogItem);
                return;
            }
            if (mcBaseLogItem.get_Name() == "Exception")
            {
                debugTreeItem.NodeName = "Exception";
                this.CreateChildNode(this._exeptionNode, debugTreeItem, mcBaseLogItem);
                return;
            }
            if (mcBaseLogItem.get_Name().StartsWith("System"))
            {
                debugTreeItem.NodeName = "System";
                this.CreateChildNode(this._systemInfoNode, debugTreeItem, mcBaseLogItem);
                return;
            }
            if (mcBaseLogItem.get_Name().StartsWith("OpenVPNLog"))
            {
                debugTreeItem.NodeName = "OpenVPNLog";
                string debugData = ((McOpenVpnLogItem)mcBaseLogItem).get_DebugData();
                debugTreeItem.Highlight = this.ContainsImportantVerb(debugData);
                if (this._currentSession == null)
                {
                    this._currentSession = this.CreateNewSession(0);
                }
                this.CreateChildNode(this._mOpenVpnNode, debugTreeItem, mcBaseLogItem);
                return;
            }
            if (mcBaseLogItem.get_Name().StartsWith("Service"))
            {
                debugTreeItem.NodeName = "Service";
                if (this._currentSession == null)
                {
                    this._currentSession = this.CreateNewSession(0);
                }
                this.CreateChildNode(this._mServiceNode, debugTreeItem, mcBaseLogItem);
                return;
            }
            if (mcBaseLogItem.get_Name().StartsWith("Gui"))
            {
                debugTreeItem.NodeName = "Gui";
                if (this._currentSession == null)
                {
                    this._currentSession = this.CreateNewSession(0);
                }
                this.CreateChildNode(this._mGuiNode, debugTreeItem, mcBaseLogItem);
            }
        }