|
|
@@ -1,13 +1,13 @@
|
|
|
/**
|
|
|
* Namespace: System.Web.UI
|
|
|
* Class: PropertyConverter
|
|
|
- *
|
|
|
+ *
|
|
|
* Author: Gaurav Vaish
|
|
|
* Maintainer: [email protected]
|
|
|
* Implementation: yes
|
|
|
* Contact: <[email protected]>
|
|
|
* Status: 100%
|
|
|
- *
|
|
|
+ *
|
|
|
* (C) Gaurav Vaish (2001)
|
|
|
*/
|
|
|
|
|
|
@@ -22,8 +22,8 @@ namespace System.Web.UI
|
|
|
{
|
|
|
private static Type[] parseMethodTypes;
|
|
|
private static Type[] parseMethodTypesWithSOP;
|
|
|
-
|
|
|
- private static PropertyConverter()
|
|
|
+
|
|
|
+ static PropertyConverter()
|
|
|
{
|
|
|
parseMethodTypes = new Type[1];
|
|
|
parseMethodTypes[0] = typeof(string);
|
|
|
@@ -31,12 +31,12 @@ namespace System.Web.UI
|
|
|
parseMethodTypesWithSOP[0] = typeof(string);
|
|
|
parseMethodTypesWithSOP[1] = typeof(IServiceProvider);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private PropertyConverter()
|
|
|
{
|
|
|
// Prevent any instance
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static object EnumFromString(Type enumType, string enumValue)
|
|
|
{
|
|
|
object retVal = null;
|
|
|
@@ -49,13 +49,13 @@ namespace System.Web.UI
|
|
|
}
|
|
|
return retVal;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static string EnumToString(Type enumType, object enumValue)
|
|
|
{
|
|
|
string retVal = Enum.Format(enumType, enumValue, "G");
|
|
|
return retVal.Replace('_','-');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static object ObjectFromString(Type objType, MemberInfo propertyInfo, string objValue)
|
|
|
{
|
|
|
if(objValue == null)
|
|
|
@@ -64,23 +64,23 @@ namespace System.Web.UI
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
- if(enumType.IsEnum)
|
|
|
+ if(objType.IsEnum)
|
|
|
{
|
|
|
return EnumFromString(objType, objValue);
|
|
|
}
|
|
|
- if(enumType.Equals(typeof(string)))
|
|
|
+ if(objType.Equals(typeof(string)))
|
|
|
{
|
|
|
return objValue;
|
|
|
}
|
|
|
PropertyDescriptor pc = null;
|
|
|
if(propertyInfo != null)
|
|
|
{
|
|
|
- pc = (TypeDesctiptor.GetProperties(propertyInfo.ReflectedType))[propertyInfo.Name];
|
|
|
+ pc = (TypeDescriptor.GetProperties(propertyInfo.ReflectedType))[propertyInfo.Name];
|
|
|
}
|
|
|
if(pc != null)
|
|
|
{
|
|
|
TypeConverter converter = pc.Converter;
|
|
|
- if(converter!=null && conveter.CanConverFrom(typeof(string)))
|
|
|
+ if(converter!=null && converter.CanConvertFrom(typeof(string)))
|
|
|
{
|
|
|
return converter.ConvertFromInvariantString(objValue);
|
|
|
}
|
|
|
@@ -94,7 +94,7 @@ namespace System.Web.UI
|
|
|
parameters[1] = CultureInfo.InvariantCulture;
|
|
|
try
|
|
|
{
|
|
|
- o = Util.InvokeMethod(propertyInfo, null, parameters);
|
|
|
+ o = Utils.InvokeMethod(mi, null, parameters);
|
|
|
} catch(Exception e)
|
|
|
{
|
|
|
}
|
|
|
@@ -108,7 +108,7 @@ namespace System.Web.UI
|
|
|
parameters[0] = objValue;
|
|
|
try
|
|
|
{
|
|
|
- o = Util.InvokeMethod(propertyInfo, null, parameters);
|
|
|
+ o = Utils.InvokeMethod(mi, null, parameters);
|
|
|
} catch(Exception e)
|
|
|
{
|
|
|
}
|
|
|
@@ -116,7 +116,7 @@ namespace System.Web.UI
|
|
|
}
|
|
|
if(o == null)
|
|
|
{
|
|
|
- throw new HttpException(HttpRuntime.FormatResourceString("Type_not_creatable_from_string", objType.FullName, objValue, propertyInfo.Name);
|
|
|
+ throw new HttpException(/*HttpRuntime.FormatResourceString(*/"Type_not_creatable_from_string"/*, objType.FullName, objValue, propertyInfo.Name)*/);
|
|
|
}
|
|
|
return o;
|
|
|
}
|