All pastes #227756 Raw Edit

xeno

public text v1 · immutable
#227756 ·published 2006-10-29 15:19 UTC
rendered paste body
Index: ComponentResourceManager.cs
===================================================================
--- ComponentResourceManager.cs	(Revision 67076)
+++ ComponentResourceManager.cs	(Arbeitskopie)
@@ -29,7 +29,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_1_1
 
 using System;
 using System.Resources;
@@ -59,20 +58,25 @@
 		{
 			string objKey = objectName + ".";
 			Type type = value.GetType ();
+			PropertyInfo[] propinfos = type.GetProperties ();
 			
-			ResourceSet rset = GetResourceSet (culture, true, true);
-			foreach (DictionaryEntry di in rset)
-			{
-				string key = di.Key as string;
-				if (key.StartsWith (objKey)) {
-					key = key.Substring (objKey.Length);
-					PropertyInfo pi = type.GetProperty (key);
-					if (pi != null && pi.CanWrite)
-						pi.SetValue (value, Convert.ChangeType (di.Value, pi.PropertyType), null);
+			foreach(PropertyInfo pinfo in propinfos) {
+				if (!pinfo.CanWrite)
+					continue;
+				
+				if (pinfo.PropertyType == typeof (System.String)) {
+					string text = GetString (objKey + pinfo.Name, culture);
+					
+					if (text != null)
+							pinfo.SetValue (value, Convert.ChangeType (text, pinfo.PropertyType), null);
+				} else {
+					object obj = GetObject (objKey + pinfo.Name, culture);
+					
+					if (obj != null)
+						pinfo.SetValue (value, Convert.ChangeType (obj, pinfo.PropertyType), null);
 				}
 			}
 		}
 	}
 }
 
-#endif