Selaa lähdekoodia

2003-04-04 Gaurav Vaish <gvaish_mono AT lycos.com>

* DeviceSpecificChoice.cs: HasTemplates { get; },
                         : FindAndApplyEvent(...)     - Completed
                         : FindAndApplyProperty(...),
                         : CheckOnPageEvaluator(...)  - Init impl.

svn path=/trunk/mcs/; revision=13140
Gaurav Vaish 23 vuotta sitten
vanhempi
sitoutus
d8d228eb8f

+ 7 - 0
mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/ChangeLog

@@ -1,4 +1,11 @@
 
+2003-04-04	Gaurav Vaish <gvaish_mono AT lycos.com>
+
+	* DeviceSpecificChoice.cs: HasTemplates { get; },
+	                         : FindAndApplyEvent(...)     - Completed
+	                         : FindAndApplyProperty(...),
+	                         : CheckOnPageEvaluator(...)  - Init impl.
+
 2003-04-03	Gaurav Vaish <gvaish_mono AT lycos.com>
 
 	* DeviceSpecific.cs      : Almost done.

+ 39 - 3
mcs/class/System.Web.Mobile/System.Web.UI.MobileControls/DeviceSpecificChoice.cs

@@ -167,21 +167,57 @@ namespace System.Web.UI.MobileControls
 			}
 		}
 
+		/// <summary>
+		/// Returns false if not found or not applied
+		/// </summary>
 		private bool FindAndApplyProperty(object parentObj, string key,
 		                                  string value)
 		{
-			throw new NotImplementedException();
+			bool retVal = false;
+			PropertyDescriptor pd =
+			    TypeDescriptor.GetProperties(parentObj).Find(key, true);
+			if(pd != null)
+			{
+				if(pd.Attributes.Contains(
+				   DesignerSerializationVisibilityAttribute.Hidden))
+				{
+					throw new ArgumentException("DeviceSpecificChoice" +
+					                 "_OverridingPropertyNotDeclarable");
+				}
+				throw new NotImplementedException();
+			}
 		}
 
 		private bool FindAndApplyEvent(object parentObj, string key,
 		                               string value)
 		{
-			throw new NotImplementedException();
+			bool retVal = false;
+			if(key.Length > 0)
+			{
+				if(key.ToLower().StartsWith("on"))
+				{
+					string eventName = key.Substring(2);
+					EventDescriptor ed =
+					      TypeDescriptor.GetEvents(parentObj).Find(key, true);
+					if(ed != null)
+					{
+						ed.AddEventHandler(parentObj,
+						  Delegate.CreateDelegate(ed.EventType,
+						          Owner.MobilePage, eventName));
+					}
+				}
+			}
+			return retVal;
 		}
 
 		private bool CheckOnPageEvaluator(MobileCapabilities capabilities,
 		                                  out bool evaluatorResult)
 		{
+			boolr retVal = false;
+			evaluatorResult = false;
+			TemplateControl tc = Owner.ClosestTemplateControl;
+			// I have to get the method (MethodInfo?) and then invoke
+			// the method and send back the results of the method!
 			throw new NotImplementedException();
 		}
 
@@ -189,7 +225,7 @@ namespace System.Web.UI.MobileControls
 		{
 			get
 			{
-				throw new NotImplementedException();
+				return (templates != null && templates.Count > 0);
 			}
 		}
 	}