crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianParserLib/TypeConverters/EnumTypeConverter.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianParserLib/TypeConverters/EnumTypeConverter.cs Thu Feb 11 15:50:58 2010 +0200
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Reflection;
+using System.ComponentModel;
+
+namespace SymbianParserLib.TypeConverters
+{
+ public class SymbianEnumConverter : EnumConverter
+ {
+ #region Constructors
+ public SymbianEnumConverter( Type aType )
+ : base( aType )
+ {
+ }
+ #endregion
+
+ #region From EnumConverter
+ public override bool CanConvertFrom( ITypeDescriptorContext aContext, Type aSourceType )
+ {
+ bool ret = base.CanConvertFrom( aContext, aSourceType );
+ //
+ if ( aSourceType == typeof( uint ) )
+ {
+ ret = true;
+ }
+ else if ( aSourceType == typeof( int ) )
+ {
+ ret = true;
+ }
+ else if ( aSourceType == typeof( ulong ) )
+ {
+ ret = true;
+ }
+ //
+ return ret;
+ }
+
+ public override object ConvertFrom( ITypeDescriptorContext aContext, System.Globalization.CultureInfo aCulture, object aValue )
+ {
+ object ret = null;
+ //
+ if ( ( aValue is uint ) || ( aValue is int ) || ( aValue is ulong ) )
+ {
+ ret = Enum.ToObject( base.EnumType, aValue );
+ }
+ else
+ {
+ ret = base.ConvertFrom( aContext, aCulture, aValue );
+ }
+ //
+ return ret;
+ }
+ #endregion
+ }
+}