Selaa lähdekoodia

2007-05-15 Marek Habersack <[email protected]>

	* TemplateControl.cs: implemented the 3-parameter overloads of
	GetLocalResourceObject and GetGlobalResourceObject.


svn path=/trunk/mcs/; revision=77440
Marek Habersack 18 vuotta sitten
vanhempi
sitoutus
97f2de6812

+ 3 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,5 +1,8 @@
 2007-05-15  Marek Habersack  <[email protected]>
 
+	* TemplateControl.cs: implemented the 3-parameter overloads of
+	GetLocalResourceObject and GetGlobalResourceObject.
+
 	* TemplateParser.cs: refactoring - use HttpApplication.LoadType to
 	actually look up types.
 	

+ 25 - 5
mcs/class/System.Web/System.Web.UI/TemplateControl.cs

@@ -284,11 +284,21 @@ namespace System.Web.UI {
 			return HttpContext.GetGlobalResourceObject (className, resourceKey);
 		}
 
-		[MonoTODO ("Not implemented")]
 		protected object GetGlobalResourceObject (string className, string resourceKey, Type objType, string propName)
 		{
-			// FIXME: not sure how to implement that one yet
-			throw new NotSupportedException();
+			if (String.IsNullOrEmpty (resourceKey) || String.IsNullOrEmpty (propName) ||
+			    String.IsNullOrEmpty (className) || objType == null)
+				return null;
+
+			object globalObject = GetGlobalResourceObject (className, resourceKey);
+			if (globalObject == null)
+				return null;
+			
+			TypeConverter converter = TypeDescriptor.GetProperties (objType) [propName].Converter;
+			if (converter == null || !converter.CanConvertFrom (globalObject.GetType ()))
+				return null;
+			
+			return converter.ConvertFrom (globalObject);
 		}
 
 		protected object GetLocalResourceObject (string resourceKey)
@@ -299,8 +309,18 @@ namespace System.Web.UI {
 		
 		protected object GetLocalResourceObject (string resourceKey, Type objType, string propName)
 		{
-			// FIXME: not sure how to implement that one yet
-			throw new NotSupportedException();
+			if (String.IsNullOrEmpty (resourceKey) || String.IsNullOrEmpty (propName) || objType == null)
+				return null;
+
+			object localObject = GetLocalResourceObject (resourceKey);
+			if (localObject == null)
+				return null;
+			
+			TypeConverter converter = TypeDescriptor.GetProperties (objType) [propName].Converter;
+			if (converter == null || !converter.CanConvertFrom (localObject.GetType ()))
+				return null;
+			
+			return converter.ConvertFrom (localObject);
 		}
 #endif