#region  --------------- Copyright Dresser Wayne Pignone -------------
/*
 * $Log: /Wrk/WayneLibraries/Wrk/Log/DeserializedLogEntry.cs $
 * 
 * 2     08-02-13 9:25 Mattias.larsson
 * FxCop fixes.
 */
#endregion

using System.Xml;
using System.Diagnostics.CodeAnalysis;
namespace Wayne.Lib.Log
{
    /// <summary>
    /// An EventLog entry that has been deserialized from a serialized form. The
    /// additional data that is supplied with the data is now only accessible as  
    /// an Xml element in the LogDataElement property. 
    /// </summary>
    public sealed class DeserializedLogEntry : EventLogEntry
    {
        #region Fields

        XmlElement logDataElement;

        #endregion

        #region Construction

        /// <summary>
        /// Internal constructor. This class is only created with the EventLogEntry.Deserialize method.
        /// </summary>
        /// <param name="logEntryNode"></param>
        internal DeserializedLogEntry(XmlElement logEntryNode)
            : base(logEntryNode)
        {
            logDataElement = logEntryNode["LogData"];
        }

        #endregion

        #region Properties

        /// <summary>
        /// Xml element that contains the additional data that was supplied with the event originally.
        /// </summary>
        [SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", MessageId = "System.Xml.XmlNode")]
        public XmlElement LogDataElement
        {
            get { return logDataElement; }
        }

        #endregion

        #region Methods

        /// <summary>
        /// Re-serializies the LogData element.
        /// </summary>
        /// <param name="xmlWriter"></param>
        protected override void WriteLogObjectData(XmlWriter xmlWriter)
        {
            base.WriteLogObjectData(xmlWriter);
            logDataElement.WriteContentTo(xmlWriter);
        }

        #endregion
    }
}