private void ModelComplexValueGetter(Object modelObject, Control control) { var sourceAttributeValue = UserInterfaceUtil.GetAttributeValue(control, _sourceAttributeName); sourceAttributeValue = (sourceAttributeValue ?? String.Empty); var declaringType = _propertyInfo.DeclaringType; if (!sourceAttributeValue.StartsWith(declaringType.FullName) && !sourceAttributeValue.StartsWith(declaringType.Name)) { var message = String.Format("Invalid source attribute '{0}'", sourceAttributeValue); throw new Exception(message); } var lastDotIndex = sourceAttributeValue.LastIndexOf('.') + 1; var propertyName = sourceAttributeValue.Substring(lastDotIndex); var sourcePropertyInfo = declaringType.GetProperty(propertyName); var container = (IComplexDataContainer)control; var propertyValue = container.Value; var sourcePropertyValue = container.Data; _propertyInfo.SetValue(modelObject, propertyValue, _paramValues); sourcePropertyInfo.SetValue(modelObject, sourcePropertyValue, null); }
public UIControlMapping(Control containerControl, String attributeName) { _cache = new Dictionary <String, ISet <PropertyControlEntity> >(); _containerControl = containerControl; _attributeName = attributeName; var allControls = UIHierarchyCache.GetChildren(_containerControl); foreach (var current in allControls) { var attrValue = UserInterfaceUtil.GetAttributeValue(current, _attributeName); var entity = PropertyNameParser(attrValue); if (entity == null) { continue; } ISet <PropertyControlEntity> @set; if (!_cache.TryGetValue(entity.ClassName, out @set)) { @set = new HashSet <PropertyControlEntity>(); _cache.Add(entity.ClassName, @set); } var propertyControl = new PropertyControlEntity(entity, current); @set.Add(propertyControl); } }
public void SetModel(Object model, Type type) { var controls = GetModelControls(type); foreach (var entity in controls) { var control = entity.Control; var dataTypeAttributeValue = UserInterfaceUtil.GetAttributeValue(control, _dataTypeAttributeName); dataTypeAttributeValue = (dataTypeAttributeValue ?? String.Empty); var worker = new UIPropertyWorker(entity.PropertyName, entity.PropertyParams, dataTypeAttributeValue, type); worker.SetValue(control, model); } }