Esempio n. 1
0
        /// <summary>
        /// Add a new display item
        /// </summary>
        /// <param name="machineName">name of the sender machine</param>
        /// <param name="appDomain">name of the sender appdomain</param>
        /// <param name="time">sender time</param>
        /// <param name="text">display text</param>
        /// <param name="parentID">parent display item id</param>
        /// <returns>the new created id for the item</returns>
        public string AddNew(string machineName, string appDomain, string time, string text, string parentID = null)
        {
            _idCounter++;
            ConsoleViewItem newItem = new ConsoleViewItem(_idCounter.ToString(), machineName, appDomain, time, text);

            Plain.Add(newItem);
            if (!String.IsNullOrWhiteSpace(parentID))
            {
                ConsoleViewItem parentItem = LookupForItem(parentID);
                if (null != parentItem)
                {
                    parentItem.Items.Add(newItem);
                }
                else
                {
                    Hierarchy.Add(newItem);
                }
            }
            else
            {
                Hierarchy.Add(newItem);
            }

            return(_idCounter.ToString());
        }
Esempio n. 2
0
        private ConsoleViewItem LookupForItem(ConsoleViewItem element, string id)
        {
            foreach (var item in element.Items)
            {
                if (item.ID == id)
                {
                    return(item);
                }
                ConsoleViewItem child = LookupForItem(item, id);
                if (null != child)
                {
                    return(child);
                }
            }

            return(null);
        }
Esempio n. 3
0
        private ConsoleViewItem LookupForItem(string id)
        {
            foreach (var item in Hierarchy)
            {
                if (item.ID == id)
                {
                    return(item);
                }
                ConsoleViewItem child = LookupForItem(item, id);
                if (null != child)
                {
                    return(child);
                }
            }

            return(null);
        }
        /// <summary>
        /// Add a new display item
        /// </summary>
        /// <param name="machineName">name of the sender machine</param>
        /// <param name="appDomain">name of the sender appdomain</param>
        /// <param name="time">sender time</param>
        /// <param name="text">display text</param>
        /// <param name="parentID">parent display item id</param>
        /// <returns>the new created id for the item</returns>
        public string AddNew(string machineName, string appDomain, string time, string text, string parentID = null)
        {
            _idCounter++;
            ConsoleViewItem newItem = new ConsoleViewItem(_idCounter.ToString(), machineName, appDomain, time, text);
            Plain.Add(newItem);
            if (!String.IsNullOrWhiteSpace(parentID))
            {
                ConsoleViewItem parentItem = LookupForItem(parentID);
                if (null != parentItem)
                    parentItem.Items.Add(newItem);
                else
                    Hierarchy.Add(newItem);
            }
            else
                Hierarchy.Add(newItem);

            return _idCounter.ToString();
        }
Esempio n. 5
0
        private string CreateHierarchyText(ConsoleViewItem element, int numSpaces, bool showTime, bool showMachine, bool showAppDomain)
        {
            string lines = String.Empty;

            numSpaces++;
            foreach (var item in element.Items)
            {
                string timeString    = "[" + item.Time + "]";
                string machineString = "[" + (String.IsNullOrWhiteSpace(item.Machine) ? _emptyMachineDefault : item.Machine) + "]";
                string domainString  = "[" + (String.IsNullOrWhiteSpace(item.AppDomain) ? _emptyAppDomainDefault : item.AppDomain) + "]";

                string line = (true == showTime ? timeString : "") +
                              (true == showMachine ? machineString : "") +
                              (true == showAppDomain ? domainString : "") +
                              CreateSpaceString(numSpaces) + item.Text + Environment.NewLine;

                line  += CreateHierarchyText(item, numSpaces + 1, showTime, showMachine, showAppDomain);
                lines += line;
            }
            return(lines);
        }
Esempio n. 6
0
        /// <summary>
        ///  Creates a System.String to display the items in reverse order
        /// </summary>
        /// <param name="showTime">show sender time</param>
        /// <param name="showMachine">show sender machine</param>
        /// <param name="showAppDomain">show sender appDomain</param>
        /// <returns>String to display</returns>
        public string CreatePlainReverseText(bool showTime, bool showMachine, bool showAppDomain)
        {
            StringBuilder sb = new StringBuilder(_stringBuilderDefaultSize);

            for (int i = Plain.Count; i > 0; i--)
            {
                ConsoleViewItem item = Plain[i - 1];

                string timeString    = "[" + item.Time + "]";
                string machineString = "[" + (String.IsNullOrWhiteSpace(item.Machine) ? _emptyMachineDefault : item.Machine) + "]";
                string domainString  = "[" + (String.IsNullOrWhiteSpace(item.AppDomain) ? _emptyAppDomainDefault : item.AppDomain) + "]";

                string line = (true == showTime ? timeString : "") +
                              (true == showMachine ? machineString : "") +
                              (true == showAppDomain ? domainString : "") +
                              item.Text;

                sb.Append(line + Environment.NewLine);
            }
            return(sb.ToString());
        }
        private string CreateHierarchyText(ConsoleViewItem element, int numSpaces, bool showTime, bool showMachine, bool showAppDomain)
        {
            string lines = String.Empty;
            numSpaces++;
            foreach (var item in element.Items)
            {
                string timeString = "[" + item.Time + "]";
                string machineString = "[" + (String.IsNullOrWhiteSpace(item.Machine) ? _emptyMachineDefault : item.Machine) + "]";
                string domainString = "[" + (String.IsNullOrWhiteSpace(item.AppDomain) ? _emptyAppDomainDefault : item.AppDomain) + "]";

                string line = (true == showTime ? timeString : "") +
                    (true == showMachine ? machineString : "") +
                    (true == showAppDomain ? domainString : "") +
                    CreateSpaceString(numSpaces) + item.Text + Environment.NewLine;

                line += CreateHierarchyText(item, numSpaces+1, showTime, showMachine, showAppDomain);
                lines += line;

            }
            return lines;
        }
        private ConsoleViewItem LookupForItem(ConsoleViewItem element, string id)
        {
            foreach (var item in element.Items)
            {
                if (item.ID == id)
                    return item;
                ConsoleViewItem child = LookupForItem(item, id);
                if (null != child)
                    return child;
            }

            return null;
        }