/// <summary>
        /// Report error when loading formatting data from object model.
        /// </summary>
        /// <param name="message"></param>
        /// <param name="typeName"></param>
        protected void ReportErrorForLoadingFromObjectModel(string message, string typeName)
        {
            XmlLoaderLoggerEntry entry = new XmlLoaderLoggerEntry();

            entry.entryType = XmlLoaderLoggerEntry.EntryType.Error;
            entry.message   = message;
            _logger.LogEntry(entry);

            _currentErrorCount++;
            if (_currentErrorCount >= _maxNumberOfErrors)
            {
                // we have to log a last error and then bail
                if (_maxNumberOfErrors > 1)
                {
                    XmlLoaderLoggerEntry lastEntry = new XmlLoaderLoggerEntry();

                    lastEntry.entryType = XmlLoaderLoggerEntry.EntryType.Error;
                    lastEntry.message   = StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyErrorsInFormattingData, typeName);
                    _logger.LogEntry(lastEntry);
                    _currentErrorCount++;
                }

                // NOTE: this exception is an internal one, and it is caught
                // internally by the calling code.
                TooManyErrorsException e = new TooManyErrorsException();

                e.errorCount = _currentErrorCount;
                throw e;
            }
        }
Beispiel #2
0
        protected void ReportErrorForLoadingFromObjectModel(string message, string typeName)
        {
            XmlLoaderLoggerEntry entry = new XmlLoaderLoggerEntry {
                entryType = XmlLoaderLoggerEntry.EntryType.Error,
                message   = message
            };

            this.logger.LogEntry(entry);
            this.currentErrorCount++;
            if (this.currentErrorCount >= this.maxNumberOfErrors)
            {
                if (this.maxNumberOfErrors > 1)
                {
                    XmlLoaderLoggerEntry entry2 = new XmlLoaderLoggerEntry {
                        entryType = XmlLoaderLoggerEntry.EntryType.Error,
                        message   = StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyErrorsInFormattingData, typeName)
                    };
                    this.logger.LogEntry(entry2);
                    this.currentErrorCount++;
                }
                TooManyErrorsException exception = new TooManyErrorsException {
                    errorCount = this.currentErrorCount
                };
                throw exception;
            }
        }
        private void ReportLogEntryHelper(string message, XmlLoaderLoggerEntry.EntryType entryType, bool failToLoadFile = false)
        {
            string currentPath         = ComputeCurrentXPath();
            XmlLoaderLoggerEntry entry = new XmlLoaderLoggerEntry();

            entry.entryType = entryType;
            entry.filePath  = this.FilePath;
            entry.xPath     = currentPath;
            entry.message   = message;

            if (failToLoadFile)
            {
                System.Management.Automation.Diagnostics.Assert(entryType == XmlLoaderLoggerEntry.EntryType.Error, "the entry type should be 'error' when a file cannot be loaded");
                entry.failToLoadFile = true;
            }

            _logger.LogEntry(entry);

            if (entryType == XmlLoaderLoggerEntry.EntryType.Error)
            {
                _currentErrorCount++;
                if (_currentErrorCount >= _maxNumberOfErrors)
                {
                    // we have to log a last error and then bail
                    if (_maxNumberOfErrors > 1)
                    {
                        XmlLoaderLoggerEntry lastEntry = new XmlLoaderLoggerEntry();

                        lastEntry.entryType = XmlLoaderLoggerEntry.EntryType.Error;
                        lastEntry.filePath  = this.FilePath;
                        lastEntry.xPath     = currentPath;
                        lastEntry.message   = StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyErrors, FilePath);
                        _logger.LogEntry(lastEntry);
                        _currentErrorCount++;
                    }

                    // NOTE: this exception is an internal one, and it is caught
                    // internally by the calling code.
                    TooManyErrorsException e = new TooManyErrorsException();

                    e.errorCount = _currentErrorCount;
                    throw e;
                }
            }
        }
Beispiel #4
0
        private void ReportLogEntryHelper(string message, XmlLoaderLoggerEntry.EntryType entryType, bool failToLoadFile = false)
        {
            string str = this.ComputeCurrentXPath();
            XmlLoaderLoggerEntry entry = new XmlLoaderLoggerEntry {
                entryType = entryType,
                filePath  = this.FilePath,
                xPath     = str,
                message   = message
            };

            if (failToLoadFile)
            {
                entry.failToLoadFile = true;
            }
            this.logger.LogEntry(entry);
            if (entryType == XmlLoaderLoggerEntry.EntryType.Error)
            {
                this.currentErrorCount++;
                if (this.currentErrorCount >= this.maxNumberOfErrors)
                {
                    if (this.maxNumberOfErrors > 1)
                    {
                        XmlLoaderLoggerEntry entry2 = new XmlLoaderLoggerEntry {
                            entryType = XmlLoaderLoggerEntry.EntryType.Error,
                            filePath  = this.FilePath,
                            xPath     = str,
                            message   = StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyErrors, this.FilePath)
                        };
                        this.logger.LogEntry(entry2);
                        this.currentErrorCount++;
                    }
                    TooManyErrorsException exception = new TooManyErrorsException {
                        errorCount = this.currentErrorCount
                    };
                    throw exception;
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Report error when loading formatting data from object model
        /// </summary>
        /// <param name="message"></param>
        /// <param name="typeName"></param>
        protected void ReportErrorForLoadingFromObjectModel(string message, string typeName)
        {
            XmlLoaderLoggerEntry entry = new XmlLoaderLoggerEntry();

            entry.entryType = XmlLoaderLoggerEntry.EntryType.Error;
            entry.message = message;
            _logger.LogEntry(entry);

            _currentErrorCount++;
            if (_currentErrorCount >= _maxNumberOfErrors)
            {
                // we have to log a last error and then bail
                if (_maxNumberOfErrors > 1)
                {
                    XmlLoaderLoggerEntry lastEntry = new XmlLoaderLoggerEntry();

                    lastEntry.entryType = XmlLoaderLoggerEntry.EntryType.Error;
                    lastEntry.message = StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyErrorsInFormattingData, typeName);
                    _logger.LogEntry(lastEntry);
                    _currentErrorCount++;
                }

                // NOTE: this exception is an internal one, and it is caught
                // internally by the calling code.
                TooManyErrorsException e = new TooManyErrorsException();

                e.errorCount = _currentErrorCount;
                throw e;
            }
        }
Beispiel #6
0
        private void ReportLogEntryHelper(string message, XmlLoaderLoggerEntry.EntryType entryType, bool failToLoadFile = false)
        {
            string currentPath = ComputeCurrentXPath();
            XmlLoaderLoggerEntry entry = new XmlLoaderLoggerEntry();

            entry.entryType = entryType;
            entry.filePath = this.FilePath;
            entry.xPath = currentPath;
            entry.message = message;

            if (failToLoadFile)
            {
                System.Management.Automation.Diagnostics.Assert(entryType == XmlLoaderLoggerEntry.EntryType.Error, "the entry type should be 'error' when a file cannot be loaded");
                entry.failToLoadFile = true;
            }

            _logger.LogEntry(entry);

            if (entryType == XmlLoaderLoggerEntry.EntryType.Error)
            {
                _currentErrorCount++;
                if (_currentErrorCount >= _maxNumberOfErrors)
                {
                    // we have to log a last error and then bail
                    if (_maxNumberOfErrors > 1)
                    {
                        XmlLoaderLoggerEntry lastEntry = new XmlLoaderLoggerEntry();

                        lastEntry.entryType = XmlLoaderLoggerEntry.EntryType.Error;
                        lastEntry.filePath = this.FilePath;
                        lastEntry.xPath = currentPath;
                        lastEntry.message = StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyErrors, FilePath);
                        _logger.LogEntry(lastEntry);
                        _currentErrorCount++;
                    }

                    // NOTE: this exception is an internal one, and it is caught
                    // internally by the calling code.
                    TooManyErrorsException e = new TooManyErrorsException();

                    e.errorCount = _currentErrorCount;
                    throw e;
                }
            }
        }
Beispiel #7
0
 private void ReportLogEntryHelper(string message, XmlLoaderLoggerEntry.EntryType entryType, bool failToLoadFile = false)
 {
     string str = this.ComputeCurrentXPath();
     XmlLoaderLoggerEntry entry = new XmlLoaderLoggerEntry {
         entryType = entryType,
         filePath = this.FilePath,
         xPath = str,
         message = message
     };
     if (failToLoadFile)
     {
         entry.failToLoadFile = true;
     }
     this.logger.LogEntry(entry);
     if (entryType == XmlLoaderLoggerEntry.EntryType.Error)
     {
         this.currentErrorCount++;
         if (this.currentErrorCount >= this.maxNumberOfErrors)
         {
             if (this.maxNumberOfErrors > 1)
             {
                 XmlLoaderLoggerEntry entry2 = new XmlLoaderLoggerEntry {
                     entryType = XmlLoaderLoggerEntry.EntryType.Error,
                     filePath = this.FilePath,
                     xPath = str,
                     message = StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyErrors, this.FilePath)
                 };
                 this.logger.LogEntry(entry2);
                 this.currentErrorCount++;
             }
             TooManyErrorsException exception = new TooManyErrorsException {
                 errorCount = this.currentErrorCount
             };
             throw exception;
         }
     }
 }
Beispiel #8
0
 protected void ReportErrorForLoadingFromObjectModel(string message, string typeName)
 {
     XmlLoaderLoggerEntry entry = new XmlLoaderLoggerEntry {
         entryType = XmlLoaderLoggerEntry.EntryType.Error,
         message = message
     };
     this.logger.LogEntry(entry);
     this.currentErrorCount++;
     if (this.currentErrorCount >= this.maxNumberOfErrors)
     {
         if (this.maxNumberOfErrors > 1)
         {
             XmlLoaderLoggerEntry entry2 = new XmlLoaderLoggerEntry {
                 entryType = XmlLoaderLoggerEntry.EntryType.Error,
                 message = StringUtil.Format(FormatAndOutXmlLoadingStrings.TooManyErrorsInFormattingData, typeName)
             };
             this.logger.LogEntry(entry2);
             this.currentErrorCount++;
         }
         TooManyErrorsException exception = new TooManyErrorsException {
             errorCount = this.currentErrorCount
         };
         throw exception;
     }
 }