crashanalysercmd/Libraries/Engine/CrashItemLib/Crash/Utils/CIVersionInfo.cs
changeset 0 818e61de6cd1
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 CrashItemLib.Crash;
       
    21 using CrashItemLib.Crash.Base;
       
    22 using CrashItemLib.Crash.Base.DataBinding;
       
    23 
       
    24 namespace CrashItemLib.Crash.Utils
       
    25 {
       
    26 	public sealed class CIVersionInfo
       
    27 	{
       
    28         #region Constructors
       
    29         internal CIVersionInfo()
       
    30             : this( string.Empty )
       
    31         {
       
    32         }
       
    33 
       
    34         internal CIVersionInfo( string aValue )
       
    35             : this( string.Empty, aValue )
       
    36         {
       
    37         }
       
    38 
       
    39         internal CIVersionInfo( string aName, string aValue )
       
    40         {
       
    41             Name = aName;
       
    42             Value = aValue;
       
    43         }
       
    44         #endregion
       
    45 
       
    46         #region API
       
    47         #endregion
       
    48 
       
    49         #region Properties
       
    50         public bool IsValid
       
    51         {
       
    52             get { return !String.IsNullOrEmpty( Value ); }
       
    53         }
       
    54 
       
    55         public string Value
       
    56         {
       
    57             get { return iValue; }
       
    58             set
       
    59             { 
       
    60                 iValue = value;
       
    61                 if ( value == null )
       
    62                 {
       
    63                     iValue = string.Empty;
       
    64                 }
       
    65             }
       
    66         }
       
    67 
       
    68         public string Name
       
    69         {
       
    70             get { return iName; }
       
    71             set
       
    72             {
       
    73                 iName = value;
       
    74                 if ( value == null )
       
    75                 {
       
    76                     iName = string.Empty;
       
    77                 }
       
    78             }
       
    79         }
       
    80         #endregion
       
    81 
       
    82         #region Operators
       
    83         public static implicit operator string( CIVersionInfo aVersion )
       
    84         {
       
    85             return aVersion.Value;
       
    86         }
       
    87 
       
    88         public static implicit operator CIVersionInfo( string aText )
       
    89         {
       
    90             return new CIVersionInfo( aText );
       
    91         }
       
    92 
       
    93         public static implicit operator CIDBRow( CIVersionInfo aVersion )
       
    94         {
       
    95             CIDBRow row = new CIDBRow();
       
    96             //
       
    97             row.Add( new CIDBCell( aVersion.Name ) );
       
    98             row.Add( new CIDBCell( aVersion.Value ) );
       
    99             //
       
   100             return row;
       
   101         }
       
   102         #endregion
       
   103 
       
   104         #region From System.Object
       
   105         public override string ToString()
       
   106         {
       
   107             StringBuilder ret = new StringBuilder();
       
   108             //
       
   109             if ( string.IsNullOrEmpty( iName ) )
       
   110             {
       
   111                 ret.Append( iValue );
       
   112             }
       
   113             else
       
   114             {
       
   115                 ret.AppendFormat( "{0} = {1}", iName, iValue );
       
   116             }
       
   117             //
       
   118             return ret.ToString();
       
   119         }
       
   120         #endregion
       
   121 
       
   122         #region Data members
       
   123         private string iValue = string.Empty;
       
   124         private string iName = string.Empty;
       
   125         #endregion
       
   126     }
       
   127 }