public static void ProcessValueItemCollectionProperty(ValueItemCollection valueItems, Dictionary <string, ValueItem> valueItemsDict, string line, string value) { //Verify to Regular expression is match with the line MatchCollection matches = RegularExpressions.PropertyRegex.Matches(line); GroupCollection groups = matches[0].Groups; string property = groups[2].Value; switch (property.ToUpper()) { case nameof(ValueItemCollectionProperties.VALUES): if (groups[10].Value == "Add") { string argument = groups[15].Value; if (!argument.StartsWith("new ")) { string valueItemName = argument.Split('.')[1]; valueItems.Values.Add(valueItemsDict[valueItemName]); } } else { int valueItemIndex = Utilities.StringToIndex(groups[5].Value); ValueItem valueItem = Utilities.GetCreateListElement <ValueItem>(valueItems.Values, valueItemIndex); ValueItemPropertyReader.ProcessValueItemProperty(valueItem, groups[8].Value, value); } break; default: valueItems.Properties[property] = Utilities.CleanXMLProperty(value); break; } }
public static C1DataColumn ParseXML(XElement xElemCol) { C1DataColumn column = new C1DataColumn(); foreach (XAttribute attribute in xElemCol.Attributes()) { column.properties[attribute.Name.ToString()] = attribute.Value; } IEnumerable <XElement> childNodes = xElemCol.Elements().Where(x => x.Name.ToString() != "GroupInfo" && x.Name.ToString() != "ValueItems"); foreach (XElement prop in childNodes) { column.Properties[prop.Name.ToString()] = prop.Value; } column.ValueItems = ValueItemCollection.ParseXML(xElemCol.Element("ValueItems")); column.groupInfo = GroupInfo.ParseXML(xElemCol.Element("GroupInfo")); return(column); }
public static ValueItemCollection ParseXML(XElement xElemValueItemCollection) { ValueItemCollection valueItemCollection = new ValueItemCollection(); foreach (XAttribute attribute in xElemValueItemCollection.Attributes()) { valueItemCollection.Properties[attribute.Name.ToString()] = attribute.Value; } IEnumerable <XElement> internalValues = xElemValueItemCollection.Element("internalValues")?.Elements(); if (internalValues != null) { foreach (XElement valueItem in internalValues) { valueItemCollection.Values.Add(ValueItem.ParseXML(valueItem)); } } return(valueItemCollection); }