|
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 CrashItemLib.Crash.Source; |
|
22 using CrashXmlPlugin.FileFormat.Node; |
|
23 using CrashXmlPlugin.FileFormat.Versions; |
|
24 |
|
25 namespace CrashXmlPlugin.FileFormat.SourceInfo |
|
26 { |
|
27 internal class CXmlNodeSourceInfo : CXmlNode |
|
28 { |
|
29 #region Constructors |
|
30 public CXmlNodeSourceInfo() |
|
31 : base( Constants.SourceInfo ) |
|
32 { |
|
33 } |
|
34 #endregion |
|
35 |
|
36 #region From CXmlNode |
|
37 protected override void XmlSerializeContent( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
38 { |
|
39 CISource source = aParameters.Container.Source; |
|
40 |
|
41 // File type |
|
42 string fileType = source.ImplementorName; |
|
43 aParameters.Writer.WriteElementString( Constants.SourceInfo_FileType, fileType ); |
|
44 |
|
45 // Version |
|
46 CXmlVersionExtended version = new CXmlVersionExtended( source.ImplementorVersion ); |
|
47 version.XmlSerialize( aParameters ); |
|
48 |
|
49 // Source file (master file) |
|
50 string masterFileName = source.MasterFileName; |
|
51 aParameters.Writer.WriteElementString( Constants.SourceInfo_MasterFile, masterFileName ); |
|
52 |
|
53 // Line number (if relevant) |
|
54 if ( source.IsLineNumberAvailable ) |
|
55 { |
|
56 aParameters.Writer.WriteElementString( Constants.SourceInfo_LineNumber, source.LineNumber.ToString() ); |
|
57 } |
|
58 } |
|
59 |
|
60 protected override void XmlSerializeChildren( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
61 { |
|
62 base.XmlSerializeChildren( aParameters ); |
|
63 |
|
64 CISourceElement source = aParameters.Container.Source; |
|
65 |
|
66 // Write any raw data |
|
67 byte[] rawData = source.InputData; |
|
68 if ( rawData != null && rawData.Length > 0 ) |
|
69 { |
|
70 aParameters.Writer.WriteStartElement( Constants.SourceInfo_RawData ); |
|
71 |
|
72 string[] lines = Utilities.ConvertBinaryDataToText( rawData, Constants.KBinaryDataMaxLineLength ); |
|
73 foreach ( string line in lines ) |
|
74 { |
|
75 if ( !string.IsNullOrEmpty( line ) ) |
|
76 { |
|
77 aParameters.Writer.WriteElementString( Constants.SourceInfo_RawData_Item, line ); |
|
78 } |
|
79 } |
|
80 |
|
81 aParameters.Writer.WriteEndElement(); |
|
82 } |
|
83 } |
|
84 #endregion |
|
85 |
|
86 #region Properties |
|
87 #endregion |
|
88 |
|
89 #region Data members |
|
90 #endregion |
|
91 } |
|
92 } |