// Helper to create a device config given the names of methods private IndividualDeviceConfig CreateDeviceConfig(ControlsConfig config, ConfigurationSectionHelper helper, String deviceName) { String nameOfDeviceToInheritFrom = helper.RemoveStringAttribute("inheritsFrom", false); if (nameOfDeviceToInheritFrom == String.Empty) { nameOfDeviceToInheritFrom = null; } bool propertiesRequired = nameOfDeviceToInheritFrom == null; String predicateClass = helper.RemoveStringAttribute("predicateClass", propertiesRequired); // If a predicate class is specified, so must a method. String predicateMethod = helper.RemoveStringAttribute("predicateMethod", predicateClass != null); String pageAdapterClass = helper.RemoveStringAttribute("pageAdapter", propertiesRequired); IndividualDeviceConfig.DeviceQualifiesDelegate predicateDelegate = null; if (predicateClass != null || predicateMethod != null) { Type predicateClassType = CheckedGetType(predicateClass, "PredicateClass", helper); try { predicateDelegate = (IndividualDeviceConfig.DeviceQualifiesDelegate) IndividualDeviceConfig.DeviceQualifiesDelegate.CreateDelegate( typeof(IndividualDeviceConfig.DeviceQualifiesDelegate), predicateClassType, predicateMethod); } catch { throw new ConfigurationException( SR.GetString(SR.MobileControlsSectionHandler_CantCreateMethodOnClass, predicateMethod, predicateClassType.FullName), helper.Node); } } Type pageAdapterType = null; if (pageAdapterClass != null) { pageAdapterType = CheckedGetType(pageAdapterClass, "PageAdapterClass", helper); } return(new IndividualDeviceConfig(config, deviceName, predicateDelegate, pageAdapterType, nameOfDeviceToInheritFrom)); }
// Essentially this method does what MobileControlSectionHandler.CreateDeviceConfig() // does, but use MobileControlsSection for retrieving config data instead private static IndividualDeviceConfig CreateDeviceConfig(ControlsConfig config, DeviceElement device) { String nameOfDeviceToInheritFrom = device.InheritsFrom; if (nameOfDeviceToInheritFrom != null && nameOfDeviceToInheritFrom.Length == 0) { nameOfDeviceToInheritFrom = null; } IndividualDeviceConfig.DeviceQualifiesDelegate predicateDelegate = null; if (device.PredicateClass != null) { // If a predicate class is specified, so must a method. // The checking is already done in MobileControlsSection Debug.Assert(!String.IsNullOrEmpty(device.PredicateMethod)); predicateDelegate = device.GetDelegate(); } return(new IndividualDeviceConfig(config, device.Name, predicateDelegate, device.PageAdapter, nameOfDeviceToInheritFrom)); }