static private void ValidateElement(object value) { Debug.Assert((value != null) && (value is DeviceElement)); DeviceElement elem = (DeviceElement)value; // If there is no inheritance the properties must exists and be valid if (string.IsNullOrEmpty(elem.InheritsFrom)) { if (elem.PredicateClass == null) { throw new ConfigurationErrorsException(SR.GetString(SR.ConfigSect_MissingValue, "predicateClass"), elem.ElementInformation.Source, elem.ElementInformation.LineNumber); } if (elem.PageAdapter == null) { throw new ConfigurationErrorsException(SR.GetString(SR.ConfigSect_MissingValue, "pageAdapter"), elem.ElementInformation.Source, elem.ElementInformation.LineNumber); } // Resolve the method elem.GetDelegate(); } }
// 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); }
// 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)); }