public static IEnumerable <IModelNode> Nodes(this IModelNode node) { for (int i = 0; i < node.NodeCount; i++) { yield return(node.GetNode(i)); } }
void DelegateValuesFromModelToControl(IModelNode optionsNode, IList <PropertyInfo> propertyInfos, MethodInfo getValueMethodInfo, object control) { for (int i = 0; i < optionsNode.NodeCount; i++) { var modelNode = optionsNode.GetNode(i); var id = modelNode.GetValue <string>("Id"); PropertyInfo propertyInfo = propertyInfos.FirstOrDefault(info => info.Name == id); if (propertyInfo != null) { object value = propertyInfo.GetValue(control, null); var properties = propertyInfo.PropertyType.GetProperties().Where(info => info.GetSetMethod() != null); foreach (PropertyInfo property in properties) { PropertyInfo info = modelNode.GetType().GetProperty(property.Name); if (info != null) { MethodInfo genericMethod = getValueMethodInfo.MakeGenericMethod(info.PropertyType); object invoke = genericMethod.Invoke(modelNode, new object[] { property.Name }); if (invoke != null) { property.SetValue(value, invoke, null); } } } } } }
static void UpdateRemovedNodes(IModelNode modelNode) { for (int i = modelNode.NodeCount - 1; i >= 0; i--) { var node = modelNode.GetNode(i); var modelNode1 = ((ModelNode)node); if (CanBeRemoved(modelNode1)) { node.Remove(); } UpdateRemovedNodes(node); } }
IModelNode GetOptionNode(IModelNode modelListViewMainViewOptionsInterfaceType) { Type modelListViewMainViewOptionsType = GetModelOptionsType(); for (int i = 0; i < modelListViewMainViewOptionsInterfaceType.NodeCount; i++) { IModelNode modelNode = modelListViewMainViewOptionsInterfaceType.GetNode(i); var id = modelNode.GetValue <string>("Id"); if (id == modelListViewMainViewOptionsType.GetProperties()[0].Name) { return(modelNode); } } return(null); }
public static ModelNode GetNodeByPath(this IModelNode node, string path) { string[] separator = { "/" }; var strArray = path.Split(separator, StringSplitOptions.RemoveEmptyEntries); var node2 = strArray[0] == "Application" ? node.Root : node.GetNode(strArray[0]); for (var i = 1; i < strArray.Length; i++) { if (node2 == null) { return(null); } node2 = node2.GetNode(strArray[i]); } return((ModelNode)node2); }
public bool IsVisible(IModelNode node, string propertyName) { var criteria = node.GetPropertyAttribute <ModelMapperBrowsableAttribute>(propertyName).Criteria; if (criteria != null) { node = node.GetNode(propertyName); var criteriaOperator = CriteriaOperator.Parse(criteria); var expressionEvaluator = new ExpressionEvaluator(new EvaluatorContextDescriptorDefault(node.GetType()), criteriaOperator, customFunctions: CustomFunctions); var isVisible = expressionEvaluator.Evaluate(node); if (isVisible != null) { return((bool)isVisible); } } return(true); }
public static ModelNode GetNodeByPath(this IModelNode node, string path) { const string rootNodeName = "Application"; Guard.ArgumentNotNull(node, "node"); Guard.ArgumentNotNullOrEmpty(path, "path"); string[] items = path.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries); var sourceNode = (items[0] == rootNodeName ? node.Root : node.GetNode(items[0])); for (int i = 1; i < items.Length; ++i) { if (sourceNode == null) { return(null); } sourceNode = sourceNode.GetNode(items[i]); } return((ModelNode)sourceNode); }