private static IList <Control> GetAllChildren(Control parent) { var collection = UserInterfaceUtil.TraverseChildren(parent, ShouldChildrenSkiped); var children = new List <Control>(collection); return(children); }
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); } }
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 Control FindControlRec(String controlID) { if (_controlsCache == null) { var allControls = UserInterfaceUtil.TraverseChildren(this); _controlsCache = allControls.ToLookup(n => n.ID); } var result = _controlsCache[controlID]; return(result.FirstOrDefault()); }
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); } }
protected IEnumerable <HyperLink> GetCurrentUrlLinks(Control control) { var links = (from n in UserInterfaceUtil.TraverseChildren(this) let l = n as HyperLink where l != null select l); foreach (var link in links) { var linkUrl = GetLinkAbsUrl(link); if (IsRequestLink(linkUrl)) { yield return(link); } } }
private static IEnumerable <String> GetAllPermissions(Control control) { var query = from n in ConfigSection.Permissions.Cast <PermissionElement>() where !string.IsNullOrWhiteSpace(n.ResourcePath) select n.ResourcePath; foreach (var path in query) { yield return(path); } var configSection = ConfigSection; if (configSection == null) { yield break; } if (ConfigSettings == null) { yield break; } if (!ConfigSettings.ResourcePathAutoGeneration) { yield break; } query = from n in UserInterfaceUtil.TraverseChildren(control) let m = n as IPermissionDependent where m != null && string.IsNullOrWhiteSpace(m.PermissionKey) let fullName = GetControlFullName(n) where !string.IsNullOrWhiteSpace(fullName) select fullName; foreach (var path in query) { yield return(path); } }
private void DisplayPopupsIfNeeded() { var enabled = DataConverter.ToNullableBool(ConfigurationManager.AppSettings["PopupsAutoControl"]); if (!enabled.GetValueOrDefault()) { return; } var target = PostBackControl; if (target == null) { return; } var parents = UserInterfaceUtil.TraverseParents(target).OfType <Panel>(); var parentPopup = parents.OfType <ModalPopup>().FirstOrDefault(); if (parentPopup != null) { parentPopup.Show(); return; } var root = ((Control)base.Master ?? this); var popups = UserInterfaceUtil.TraverseChildren(root).OfType <ModalPopupExtender>(); var @set = parents.Select(n => n.ID).ToHashSet(); var pops = popups.Where(n => @set.Contains(n.PopupControlID)); foreach (var item in pops) { item.Show(); } }