crashanalysercmd/Libraries/File Formats/Plugins/CrashXmlPlugin/FileFormat/Document/CXmlDocumentRoot.cs
changeset 0 818e61de6cd1
child 3 045ade241ef5
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 using System;
       
    18 using System.Text;
       
    19 using System.Collections.Generic;
       
    20 using System.Xml;
       
    21 using CrashXmlPlugin.FileFormat.CrashAnalyser;
       
    22 using CrashXmlPlugin.FileFormat.SourceInfo;
       
    23 using CrashXmlPlugin.FileFormat.Segment;
       
    24 using CrashXmlPlugin.FileFormat.Node;
       
    25 using SymbianTree;
       
    26 
       
    27 namespace CrashXmlPlugin.FileFormat.Document
       
    28 {
       
    29     internal class CXmlDocumentRoot : SymDocument
       
    30 	{
       
    31 		#region Constructors
       
    32         public CXmlDocumentRoot()
       
    33 		{
       
    34             base.Add( new CXmlNodeCrashAnalyser() );
       
    35             base.Add( new CXmlNodeSourceInfo() );
       
    36 
       
    37             // Segment table must be serialized first - it writes its data to a memory buffer
       
    38             base.Add( new CXmlNodeSegmentTable() );
       
    39 
       
    40             // ... and then the dictionary writes its data to the underlying file, after which
       
    41             // it appends the serialized segment table memory-buffer
       
    42             base.Add( new CXmlNodeSegmentDictionary() );
       
    43         }
       
    44 		#endregion
       
    45 
       
    46         #region API
       
    47         public void XmlSerialize( CXmlDocumentSerializationParameters aParameters )
       
    48         {
       
    49             string nodeName = XmlNodeName;
       
    50             //
       
    51             aParameters.Writer.WriteStartElement( null, nodeName, null );
       
    52             XmlSerializeChildren( aParameters );
       
    53             aParameters.Writer.WriteEndElement();
       
    54         }
       
    55         #endregion
       
    56 
       
    57         #region Properties
       
    58         public CXmlNodeCrashAnalyser CrashAnalyser
       
    59         {
       
    60             get { return (CXmlNodeCrashAnalyser) base.ChildByType( typeof( CXmlNodeCrashAnalyser ) ); }
       
    61         }
       
    62 
       
    63         public CXmlNodeSourceInfo SourceInfo
       
    64         {
       
    65             get { return (CXmlNodeSourceInfo) base.ChildByType( typeof( CXmlNodeSourceInfo ) ); }
       
    66         }
       
    67 
       
    68         public CXmlNodeSegmentDictionary SegmentDictionary
       
    69         {
       
    70             get { return (CXmlNodeSegmentDictionary) base.ChildByType( typeof( CXmlNodeSegmentDictionary ) ); }
       
    71         }
       
    72 
       
    73         public CXmlNodeSegmentTable SegmentTable
       
    74         {
       
    75             get { return (CXmlNodeSegmentTable) base.ChildByType( typeof( CXmlNodeSegmentTable ) ); }
       
    76         }
       
    77         #endregion
       
    78 
       
    79         #region Internal methods
       
    80         private void XmlSerializeChildren( CXmlDocumentSerializationParameters aParameters )
       
    81         {
       
    82             foreach ( SymNode node in this )
       
    83             {
       
    84                 if ( node is CXmlNode )
       
    85                 {
       
    86                     CXmlNode xmlNode = (CXmlNode) node;
       
    87                     xmlNode.XmlSerialize( aParameters );
       
    88                 }
       
    89             }
       
    90         }
       
    91         #endregion
       
    92 
       
    93         #region From SymNode
       
    94         protected override string XmlNodeName
       
    95         {
       
    96             get
       
    97             {
       
    98                 return Constants.RootNode;
       
    99             }
       
   100         }
       
   101         #endregion
       
   102 
       
   103         #region Data members
       
   104 		#endregion
       
   105 	}
       
   106 }