//解析Targets节点
        private void ParseTargets(XmlNodeList nodes)
        {
            foreach (XmlNode node in nodes)
            {
                if (node is XmlComment)
                {
                    continue;
                }

                var config = new TargetConfig();
                config.Name        = GetAttribute(node, "name", true);
                config.ChildConfig = node.ChildNodes;

                config.FormatterName = GetAttribute(node, "formatter", false);
                if (string.IsNullOrEmpty(config.FormatterName))
                {
                    config.FormatterName = "DefaultFormatter";
                }

                string typeName = GetAttribute(node, "type", true);
                if (!typeName.Contains("."))
                {
                    typeName = "Kalman.Logging.Targets." + typeName;
                }

                config.TargetType = Type.GetType(typeName, false);
                if (config.TargetType == null)
                {
                    throw new ConfigurationErrorsException(string.Format("找不到类型名称为{0}的Target", typeName));
                }

                _Targets.Add(config);
            }
        }
Beispiel #2
0
        //解析Targets节点
        private void ParseTargets(XmlNodeList nodes)
        {
            foreach (XmlNode node in nodes)
            {
                if (node is XmlComment)                    continue;

                var config = new TargetConfig();
                config.Name = GetAttribute(node, "name", true);
                config.ChildConfig = node.ChildNodes;

                config.FormatterName = GetAttribute(node, "formatter", false);
                if (string.IsNullOrEmpty(config.FormatterName))
                    config.FormatterName = "DefaultFormatter";

                string typeName = GetAttribute(node, "type", true);
                if (!typeName.Contains("."))
                    typeName = "Kalman.Logging.Targets." + typeName;

                config.TargetType = Type.GetType(typeName, false);
                if (config.TargetType == null)
                    throw new ConfigurationErrorsException(string.Format("找不到类型名称为{0}的Target",typeName));

                _Targets.Add(config);
            }
        }