コード例 #1
0
        public void LogWarning(XmlNode referenceNode, string message, params object[] messageArgs)
        {
            if (SupressWarnings)
            {
                // SupressWarnings downgrade the Warning to LogMessage
                LogMessage(message, messageArgs);
            }
            else
            {
                if (_externalLogger != null)
                {
                    string fileName = ConvertUriToFileName(referenceNode.OwnerDocument);
                    var    lineInfo = referenceNode as IXmlLineInfo;

                    if (lineInfo != null)
                    {
                        _externalLogger.LogWarning(
                            fileName,
                            lineInfo.LineNumber,
                            lineInfo.LinePosition,
                            message,
                            messageArgs);
                    }
                    else
                    {
                        _externalLogger.LogWarning(
                            fileName,
                            message,
                            messageArgs);
                    }
                }
            }
        }
コード例 #2
0
        void ApplyTransformation(string configFile, string transformFile, string destinationFile, IXmlTransformationLogger logger)
        {
            errorEncountered = false;
            var transformation = new XmlTransformation(transformFile, logger);

            var configurationFileDocument = new XmlTransformableDocument()
            {
                PreserveWhitespace = true
            };

            configurationFileDocument.Load(configFile);

            var success = transformation.Apply(configurationFileDocument);

            if (!success || errorEncountered)
            {
                throw new CommandException($"The XML configuration file {configFile} failed with transformation file {transformFile}.");
            }

            if (!configurationFileDocument.ChildNodes.OfType <XmlElement>().Any())
            {
                logger.LogWarning("The XML configuration file {0} no longer has a root element and is invalid after being transformed by {1}", new object[] { configFile, transformFile });
            }

            configurationFileDocument.Save(destinationFile);
        }
コード例 #3
0
 public void LogWarning(string message, params object[] messageArgs)
 {
     if (SupressWarnings)
     {
         // SupressWarnings downgrade the Warning to LogMessage
         LogMessage(message, messageArgs);
     }
     else
     {
         if (CurrentReferenceNode != null)
         {
             LogWarning(CurrentReferenceNode, message, messageArgs);
         }
         else if (externalLogger != null)
         {
             externalLogger.LogWarning(message, messageArgs);
         }
     }
 }