|
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 CrashXmlPlugin.FileFormat.Node; |
|
21 |
|
22 namespace CrashXmlPlugin.FileFormat.Versions |
|
23 { |
|
24 internal class CXmlVersionExtended : CXmlNode |
|
25 { |
|
26 #region Constructors |
|
27 public CXmlVersionExtended() |
|
28 : base( Constants.Version_Extended ) |
|
29 { |
|
30 } |
|
31 |
|
32 public CXmlVersionExtended( Version aVersion ) |
|
33 : this( aVersion.Major, aVersion.Minor ) |
|
34 { |
|
35 // Version supports 4 levels of versining information: |
|
36 // |
|
37 // major.minor.build.revision |
|
38 // |
|
39 // This object only supports two: |
|
40 // |
|
41 // major.minor |
|
42 // |
|
43 // However, "this.minor" can encapsulate both Version.minor and Version.build. |
|
44 // |
|
45 iMinor = ( aVersion.Minor * 10 ) + aVersion.Build; |
|
46 } |
|
47 |
|
48 public CXmlVersionExtended( int aMajor ) |
|
49 : this( aMajor, 0 ) |
|
50 { |
|
51 } |
|
52 |
|
53 public CXmlVersionExtended( int aMajor, int aMinor ) |
|
54 : this() |
|
55 { |
|
56 iMajor = aMajor; |
|
57 iMinor = aMinor; |
|
58 } |
|
59 #endregion |
|
60 |
|
61 #region From CXmlNode |
|
62 protected override void XmlSerializeChildren( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
63 { |
|
64 aParameters.Writer.WriteElementString( Constants.Version_Extended_Major, Major.ToString() ); |
|
65 aParameters.Writer.WriteElementString( Constants.Version_Extended_Minor, Minor.ToString( "d2" ) ); |
|
66 } |
|
67 #endregion |
|
68 |
|
69 #region Properties |
|
70 public int Major |
|
71 { |
|
72 get { return iMajor; } |
|
73 set { iMajor = value; } |
|
74 } |
|
75 |
|
76 public int Minor |
|
77 { |
|
78 get { return iMinor; } |
|
79 set { iMinor = value; } |
|
80 } |
|
81 #endregion |
|
82 |
|
83 #region From System.Object |
|
84 public override string ToString() |
|
85 { |
|
86 StringBuilder ret = new StringBuilder(); |
|
87 ret.AppendFormat( "{0}.{1:d2}", Major, Minor ); |
|
88 return ret.ToString(); |
|
89 } |
|
90 #endregion |
|
91 |
|
92 #region Data members |
|
93 private int iMajor = 1; |
|
94 private int iMinor = 0; |
|
95 #endregion |
|
96 } |
|
97 } |