Exemplo n.º 1
0
        public void PerformTransform(string configFile, string transformFile, string destinationFile)
        {
            var transformFailed = false;
            var transformWarning = "";
            var logger = new VerboseTransformLogger(_suppressTransformationErrors, _suppressTransformationLogging);
            logger.Warning += (sender, args) =>
            {
                transformWarning = args.Message;
                transformFailed = true;
            };
            if (_suppressTransformationErrors)
            {
                Log.Info("XML Transformation warnings will be suppressed.");
            }

            var transformation = new XmlTransformation(transformFile, logger);

            var configurationFileDocument = new XmlTransformableDocument();
            configurationFileDocument.PreserveWhitespace = true;
            configurationFileDocument.Load(configFile);

            var success = transformation.Apply(configurationFileDocument);

            if (!_suppressTransformationErrors && (!success || transformFailed))
            {
                Log.ErrorFormat("The XML configuration file {0} failed with transformation file {1}.", configFile, transformFile);
                throw new CommandException(transformWarning);
            }

            configurationFileDocument.Save(destinationFile);
        }
Exemplo n.º 2
0
        public void PerformTransform(string configFile, string transformFile, string destinationFile)
        {
            var transformFailed  = false;
            var transformWarning = "";
            var logger           = new VerboseTransformLogger(_suppressTransformationErrors, _suppressTransformationLogging);

            logger.Warning += (sender, args) =>
            {
                transformWarning = args.Message;
                transformFailed  = true;
            };
            if (_suppressTransformationErrors)
            {
                Log.Info("XML Transformation warnings will be suppressed.");
            }

            var transformation = new XmlTransformation(transformFile, logger);

            var configurationFileDocument = new XmlTransformableDocument();

            configurationFileDocument.PreserveWhitespace = true;
            configurationFileDocument.Load(configFile);

            var success = transformation.Apply(configurationFileDocument);

            if (!_suppressTransformationErrors && (!success || transformFailed))
            {
                Log.ErrorFormat("The XML configuration file {0} failed with transformation file {1}.", configFile, transformFile);
                throw new CommandException(transformWarning);
            }

            configurationFileDocument.Save(destinationFile);
        }
        IXmlTransformationLogger SetupLogger()
        {
            transformFailed = false;
            transformWarning = default(string);
            
            var logger = new VerboseTransformLogger(suppressTransformationErrors, suppressTransformationLogging);
            logger.Warning += (sender, args) =>
            {
                transformWarning = args.Message;
                transformFailed = true;
            };
            if (suppressTransformationErrors)
            {
                Log.Info("XML Transformation warnings will be suppressed.");
            }

            return logger;
        }
Exemplo n.º 4
0
        IXmlTransformationLogger SetupLogger()
        {
            transformFailed  = false;
            transformWarning = default(string);

            var logger = new VerboseTransformLogger(suppressTransformationErrors, suppressTransformationLogging);

            logger.Warning += (sender, args) =>
            {
                transformWarning = args.Message;
                transformFailed  = true;
            };
            if (suppressTransformationErrors)
            {
                Log.Info("XML Transformation warnings will be suppressed.");
            }

            return(logger);
        }
Exemplo n.º 5
0
        IXmlTransformationLogger SetupLogger()
        {
            var logger = new VerboseTransformLogger(transformLoggingOptions, calamariLog);

            logger.Error += delegate { errorEncountered = true; };
            if (transformLoggingOptions.HasFlag(TransformLoggingOptions.DoNotLogVerbose))
            {
                calamariLog.Verbose($"Verbose XML transformation logging has been turned off because the variable {SpecialVariables.Package.SuppressConfigTransformationLogging} has been set to true.");
            }
            if (transformLoggingOptions.HasFlag(TransformLoggingOptions.LogExceptionsAsWarnings))
            {
                calamariLog.Verbose($"XML transformation warnings will be downgraded to information because the variable {SpecialVariables.Package.IgnoreConfigTransformationErrors} has been set to true.");
            }
            if (transformLoggingOptions.HasFlag(TransformLoggingOptions.LogExceptionsAsWarnings))
            {
                calamariLog.Verbose($"XML transformation exceptions will be downgraded to warnings because the variable {SpecialVariables.Package.IgnoreConfigTransformationErrors} has been set to true.");
            }
            if (transformLoggingOptions.HasFlag(TransformLoggingOptions.LogWarningsAsErrors))
            {
                calamariLog.Verbose($"Warning will be elevated to errors. Prevent this by adding the variable {SpecialVariables.Package.TreatConfigTransformationWarningsAsErrors} and setting it to false.");
            }

            return(logger);
        }