public void AddComplexObjectsToBuilder(StringBuilder result, IComplexObjectItemModel complexObjectItemModel) { result.Append("<"); var name = complexObjectItemModel.DisplayName; if (complexObjectItemModel.IsArray || name.EndsWith("()")) { name = name.Replace("()", ""); } result.AppendFormat("{0} {1}=\"{2}\" {3}=\"{4}\" IsJson=\"{5}\" IsArray=\"{6}\" {7}=\"{8}\">" , name , Common.Description , complexObjectItemModel.Description , Common.IsEditable , complexObjectItemModel.IsEditable , true , complexObjectItemModel.IsArray , GlobalConstants.DataListIoColDirection , complexObjectItemModel.ColumnIODirection ); var complexObjectItemModels = complexObjectItemModel.Children.Where(model => !string.IsNullOrEmpty(model.DisplayName) && !model.HasError); foreach (var itemModel in complexObjectItemModels) { AddComplexObjectsToBuilder(result, itemModel); } result.Append("</"); result.Append(name); result.Append(">"); }
void ProcessObjectForComplexObjectCollection(IComplexObjectItemModel parentObj, JObject objToProcess) { if (objToProcess != null) { ProcessJObject(parentObj, objToProcess); } }
public void AddComplexObjectFromXmlNode(XmlNode xmlNode, IComplexObjectItemModel parent) { var isArray = false; var ioDirection = enDev2ColumnArgumentDirection.None; if (xmlNode.Attributes != null) { isArray = Common.ParseBoolAttribute(xmlNode.Attributes["IsArray"]); ioDirection = Common.ParseColumnIODirection(xmlNode.Attributes[GlobalConstants.DataListIoColDirection]); } var name = GetNameForArrayComplexObject(xmlNode, isArray); var complexObjectItemModel = new ComplexObjectItemModel(name) { IsArray = isArray, Parent = parent, ColumnIODirection = ioDirection }; if (parent != null) { parent.Children.Add(complexObjectItemModel); } else { _vm.Add(complexObjectItemModel); } if (xmlNode.HasChildNodes) { var children = xmlNode.ChildNodes; foreach (XmlNode childNode in children) { AddComplexObjectFromXmlNode(childNode, complexObjectItemModel); } } }
void SetComplexObjectParentIsUsed(IComplexObjectItemModel complexObjectItemModel) { complexObjectItemModel.IsUsed = true; if (complexObjectItemModel.Parent != null) { SetComplexObjectParentIsUsed(complexObjectItemModel.Parent); } }
public void RemoveUnusedChildComplexObjects(IComplexObjectItemModel parentItemModel, IComplexObjectItemModel complexObjectItemModel) { for (int index = parentItemModel.Children.Count - 1; index >= 0; index--) { RemoveUnusedChildComplexObjects(parentItemModel.Children[index], complexObjectItemModel); parentItemModel.Children.Remove(complexObjectItemModel); } }
public void AddComplexObject(IDataListVerifyPart part) { var paths = part.DisplayValue.Split('.'); IComplexObjectItemModel itemModel = null; for (var index = 0; index < paths.Length; index++) { var path = paths[index]; if (string.IsNullOrEmpty(path) || char.IsNumber(path[0])) { return; } path = DataListUtil.ReplaceRecordsetIndexWithBlank(path); var pathToMatch = path.Replace("@", ""); if (string.IsNullOrEmpty(pathToMatch) || pathToMatch == "()") { return; } var isArray = DataListUtil.IsArray(ref path); if (itemModel == null) { itemModel = _vm.ComplexObjectCollection.FirstOrDefault( model => model.DisplayName == pathToMatch && model.IsArray == isArray); if (itemModel != null) { continue; } itemModel = new ComplexObjectItemModel(path) { IsArray = isArray }; _vm.ComplexObjectCollection.Add(itemModel); } else { if (index == 0) { continue; } var item = itemModel.Children.FirstOrDefault( model => model.DisplayName == pathToMatch && model.IsArray == isArray); if (item == null) { item = new ComplexObjectItemModel(path) { Parent = itemModel, IsArray = isArray }; itemModel.Children.Add(item); } itemModel = item; } } }
//public ComplexObjectItemModel(string displayname, IComplexObjectItemModel parent, enDev2ColumnArgumentDirection dev2ColumnArgumentDirection, string description, OptomizedObservableCollection<IComplexObjectItemModel> children, bool hasError, string errorMessage, bool isEditable, bool isVisible, bool isSelected, bool isExpanded) public ComplexObjectItemModel(string displayname, IComplexObjectItemModel parent, enDev2ColumnArgumentDirection dev2ColumnArgumentDirection, string description, OptomizedObservableCollection <IComplexObjectItemModel> children, bool hasError, string errorMessage, bool isEditable, bool isVisible, bool isSelected, bool isExpanded) : base(displayname, dev2ColumnArgumentDirection, description, hasError, errorMessage, isEditable, isVisible, isSelected, isExpanded) { Children = children; Parent = parent; if (parent == null && !Name.StartsWith("@", StringComparison.CurrentCulture)) { Name = "@" + DisplayName; } }
private void ViewJsonObjects(IComplexObjectItemModel item) { if (item != null) { if (JsonObjectsView != null) { var json = item.GetJson(); JsonObjectsView.ShowJsonString(JSONUtils.Format(json)); } } }
public ComplexObjectItemModel(string displayname, IComplexObjectItemModel parent = null, enDev2ColumnArgumentDirection dev2ColumnArgumentDirection = enDev2ColumnArgumentDirection.None, string description = "", OptomizedObservableCollection <IComplexObjectItemModel> children = null, bool hasError = false, string errorMessage = "", bool isEditable = true, bool isVisible = true, bool isSelected = false, bool isExpanded = true) : base(displayname, dev2ColumnArgumentDirection, description, hasError, errorMessage, isEditable, isVisible, isSelected, isExpanded) { Children = children; Parent = parent; if (parent == null) { if (!Name.StartsWith("@")) { Name = "@" + DisplayName; } } }
public bool Equals(IComplexObjectItemModel other) { var equals = Equals(IsArray, other.IsArray); equals &= Equals(HasError, other.HasError); equals &= Equals(Input, other.Input); equals &= Equals(Output, other.Output); equals &= string.Equals(Name, other.Name); var collectionEquals = CommonEqualityOps.CollectionEquals(Children, other.Children, new ComplexObjectItemModelComparer()); return(base.Equals(other) && equals && collectionEquals); }
private static void ViewJsonObjects(IComplexObjectItemModel item) { if (item != null) { var window = new JsonObjectsView { Height = 280 }; var contentPresenter = window.FindChild <TextBox>(); if (contentPresenter != null) { var json = item.GetJson(); contentPresenter.Text = JSONUtils.Format(json); } window.ShowDialog(); } }
private void ProcessObjectForComplexObjectCollection(IComplexObjectItemModel parentObj, JObject objToProcess) { if (objToProcess != null) { var properties = objToProcess.Properties(); foreach (var property in properties) { var displayname = property.Name; displayname = JPropertyExtensionMethods.IsEnumerable(property) ? displayname + "()" : displayname; var childObj = parentObj.Children.FirstOrDefault(model => model.DisplayName == displayname); if (childObj == null) { childObj = new ComplexObjectItemModel(displayname, parentObj) { IsArray = JPropertyExtensionMethods.IsEnumerable(property) }; parentObj.Children.Add(childObj); } if (property.Value.IsObject()) { ProcessObjectForComplexObjectCollection(childObj, property.Value as JObject); } else { if (!property.Value.IsEnumerable()) { continue; } var arrayVal = property.Value as JArray; if (arrayVal == null) { continue; } var obj = arrayVal.FirstOrDefault() as JObject; if (obj != null) { ProcessObjectForComplexObjectCollection(childObj, obj); } } } } }
private void RemoveUnusedChildComplexObjects(IComplexObjectItemModel parentItemModel, IComplexObjectItemModel itemToRemove) { _complexObjectHandler.RemoveUnusedChildComplexObjects(parentItemModel, itemToRemove); }
public ComplexObjectItemModel(string displayname, IComplexObjectItemModel parent, enDev2ColumnArgumentDirection dev2ColumnArgumentDirection) : this(displayname, parent, dev2ColumnArgumentDirection, "", null, false, "", true, true, false, true) { }