#Region "File Description"
'----------------------------------------------------------------------------- 
' ErrorLogger.cs 
' 
' Microsoft XNA Community Game Platform 
' Copyright (C) Microsoft Corporation. All rights reserved. 
'----------------------------------------------------------------------------- 
#End Region

#Region "Using Statements"
Imports System.Collections.Generic
Imports Microsoft.Build.Framework
#End Region

''' <summary> 
''' Custom implementation of the MSBuild ILogger interface records 
''' content build errors so we can later display them to the user. 
''' </summary> 
Class ErrorLogger
    Implements ILogger
    ''' <summary> 
    ''' Initializes the custom logger, hooking the ErrorRaised notification event. 
    ''' </summary> 
    Public Sub Initialize(ByVal eventSource As IEventSource) Implements ILogger.Initialize
        If eventSource IsNot Nothing Then
            AddHandler eventSource.ErrorRaised, AddressOf ErrorRaised
        End If
    End Sub


    ''' <summary> 
    ''' Shuts down the custom logger. 
    ''' </summary> 
    Public Sub Shutdown() Implements ILogger.Shutdown
    End Sub


    ''' <summary> 
    ''' Handles error notification events by storing the error message string. 
    ''' </summary> 
    Private Sub ErrorRaised(ByVal sender As Object, ByVal e As BuildErrorEventArgs)
        m_errors.Add(e.Message)
    End Sub


    ''' <summary> 
    ''' Gets a list of all the errors that have been logged. 
    ''' </summary> 
    Public ReadOnly Property Errors() As List(Of String)
        Get
            Return m_errors
        End Get
    End Property

    Private m_errors As New List(Of String)()


#Region "ILogger Members"


    ''' <summary> 
    ''' Implement the ILogger.Parameters property. 
    ''' </summary> 
    Private Property Parameters() As String Implements ILogger.Parameters
        Get
            Return m_parameters
        End Get
        Set(ByVal value As String)
            m_parameters = value
        End Set
    End Property

    Private m_parameters As String


    ''' <summary> 
    ''' Implement the ILogger.Verbosity property. 
    ''' </summary> 
    Private Property Verbosity() As LoggerVerbosity Implements ILogger.Verbosity
        Get
            Return m_verbosity
        End Get
        Set(ByVal value As LoggerVerbosity)
            m_verbosity = value
        End Set
    End Property

    Private m_verbosity As LoggerVerbosity = LoggerVerbosity.Normal


#End Region
End Class