Пример #1
0
        /// <summary>
        ///     Gets the configuration.
        /// </summary>
        /// <returns></returns>
        public string GetConfiguration()
        {
            if (_log.Enabled)
            {
                _log.Debug(GetHashCode(), "GetConfiguration");
            }
            var x = new XmlDocument();
            //<viewer type = "Text" buffer="5000" forecolor="Lime" backcolor="Black" font="Courier New" fontsize="9" >
            XmlElement viewer = x.CreateElement("viewer");

            x.AppendChild(viewer);

            XmlAttribute a = x.CreateAttribute("type");

            a.InnerText = "Text";
            viewer.Attributes.Append(a);

            a           = x.CreateAttribute("buffer");
            a.InnerText = _bufferSize.ToString();
            viewer.Attributes.Append(a);

            a           = x.CreateAttribute("forecolor");
            a.InnerText = Txt.ForeColor.Name;
            viewer.Attributes.Append(a);

            a           = x.CreateAttribute("backcolor");
            a.InnerText = Txt.BackColor.Name;
            viewer.Attributes.Append(a);

            a           = x.CreateAttribute("font");
            a.InnerText = Txt.Font.Name;
            viewer.Attributes.Append(a);

            a           = x.CreateAttribute("fontsize");
            a.InnerText = Txt.Font.Size.ToString(CultureInfo.InvariantCulture);
            viewer.Attributes.Append(a);

            a           = x.CreateAttribute("cacheOnPause");
            a.InnerText = _cacheOnPause.ToString();
            viewer.Attributes.Append(a);

            a           = x.CreateAttribute("logFileName");
            a.InnerText = LogFile;
            viewer.Attributes.Append(a);

            a           = x.CreateAttribute("logRoll");
            a.InnerText = LogRolling;
            viewer.Attributes.Append(a);

            a           = x.CreateAttribute("useLog");
            a.InnerText = LogToFile.ToString();
            viewer.Attributes.Append(a);

            foreach (Action action in _actions)
            {
                XmlNode actionNode = x.CreateElement("action");
                a       = x.CreateAttribute("type");
                a.Value = action.ActionType.ToString();
                actionNode.Attributes.Append(a);

                a       = x.CreateAttribute("pattern");
                a.Value = action.Pattern;
                actionNode.Attributes.Append(a);

                a       = x.CreateAttribute("data");
                a.Value = action.Data;
                actionNode.Attributes.Append(a);

                a = CreateActionFormatAttributes(action, actionNode);

                viewer.AppendChild(actionNode);
            }

            return(x.OuterXml);
        }