|
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.Xml; |
|
20 using System.Collections.Generic; |
|
21 using CrashItemLib.Crash.Base; |
|
22 using CrashItemLib.Crash.Memory; |
|
23 using CrashXmlPlugin.FileFormat.Node; |
|
24 |
|
25 namespace CrashXmlPlugin.FileFormat.Segment.Entries.Memory |
|
26 { |
|
27 internal class CXmlMemoryInfo : CXmlNode |
|
28 { |
|
29 #region Constructors |
|
30 public CXmlMemoryInfo( CIMemoryInfo aInfo, string aName ) |
|
31 : base( aName ) |
|
32 { |
|
33 iInfo = aInfo; |
|
34 } |
|
35 #endregion |
|
36 |
|
37 #region From CXmlNode |
|
38 protected override void XmlSerializeContent( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
39 { |
|
40 CXmlNode.WriteId( iInfo, aParameters.Writer ); |
|
41 WriteIfNotZero( aParameters.Writer, SegConstants.CmnName, iInfo.Free ); |
|
42 WriteIfNotZero( aParameters.Writer, SegConstants.MemoryInfo_Capacity, iInfo.Capacity ); |
|
43 |
|
44 if ( iInfo.Type == CIMemoryInfo.TType.ETypeDrive ) |
|
45 { |
|
46 WriteDrivePath( aParameters.Writer, iInfo.DriveNumber ); |
|
47 WriteIfNotZero( aParameters.Writer, SegConstants.MemoryInfo_UID, iInfo.UID ); |
|
48 WriteStringIfNotEmpty( aParameters.Writer, SegConstants.MemoryInfo_Drive_Vendor, iInfo.Vendor ); |
|
49 } |
|
50 else if ( iInfo.Type == CIMemoryInfo.TType.ETypeRAM ) |
|
51 { |
|
52 } |
|
53 |
|
54 // Reuse "name" tag for volume name |
|
55 WriteStringIfNotEmpty( aParameters.Writer, SegConstants.CmnName, iInfo.VolumeName ); |
|
56 } |
|
57 #endregion |
|
58 |
|
59 #region Internal methods |
|
60 private void WriteIfNotZero( XmlWriter aWriter, string aName, ulong aValue ) |
|
61 { |
|
62 if ( aValue != 0 ) |
|
63 { |
|
64 aWriter.WriteElementString( aName, aValue.ToString() ); |
|
65 } |
|
66 } |
|
67 |
|
68 private static void WriteDrivePath( XmlWriter aWriter, int aDriveNumber ) |
|
69 { |
|
70 char driveLetter = ( (char) ( (int) 'A' + aDriveNumber ) ); |
|
71 string path = driveLetter + ":"; |
|
72 // |
|
73 aWriter.WriteElementString( SegConstants.MemoryInfo_Drive_Path, path ); |
|
74 } |
|
75 #endregion |
|
76 |
|
77 #region Data members |
|
78 private readonly CIMemoryInfo iInfo; |
|
79 #endregion |
|
80 } |
|
81 } |