From ba01533df9800b47b2debc1ae11965ea08cda300 Mon Sep 17 00:00:00 2001 From: asayre Date: Mon, 2 Jan 2012 14:25:42 +0000 Subject: [PATCH] --- Server/Region.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Server/Region.cs b/Server/Region.cs index a7c32c74c..9429f09b8 100644 --- a/Server/Region.cs +++ b/Server/Region.cs @@ -1131,23 +1131,24 @@ namespace Server return ReadEnum( xml, attribute, ref value, true ); } - public static bool ReadEnum( XmlElement xml, string attribute, ref T value, bool mandatory ) where T : struct + public static bool ReadEnum( XmlElement xml, string attribute, ref T value, bool mandatory ) where T : struct // We can't limit the where clause to Enums only :( { string s = GetAttribute( xml, attribute, mandatory ); if ( s == null ) return false; + Type type = typeof(T); T tempVal; - if( Enum.TryParse( s, true, out tempVal ) ) + if( type.IsEnum && Enum.TryParse( s, true, out tempVal ) ) { value = tempVal; return true; } else { - Console.WriteLine( "Could not parse {0} enum attribute '{1}' in element '{2}'", typeof(T), attribute, xml.Name ); + Console.WriteLine( "Could not parse {0} enum attribute '{1}' in element '{2}'", attribute, xml.Name ); return false; } }