コード例 #1
0
        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;
            }
        }
コード例 #2
0
        public static ValueItem ParseXML(XElement xElemValueItem)
        {
            ValueItem valueItem = new ValueItem();

            valueItem.Value   = xElemValueItem.Attribute("Value").Value;
            valueItem.DispVal = xElemValueItem.Attribute("dispVal")?.Value;
            return(valueItem);
        }
        public static void ProcessValueItemProperty(ValueItem valueItem, string property, string value)
        {
            switch (property.ToUpper())
            {
            case nameof(ValueItemProperties.VALUE):
                valueItem.Value = Utilities.RemoveBeginEndQuotes(value);
                break;

            case nameof(ValueItemProperties.DISPLAYVALUE):
                valueItem.DispVal = Utilities.RemoveBeginEndQuotes(value);
                break;

            default:
                Console.WriteLine($"Not processed '{property}' with value '{value}' at ValueItemPropertyReader");
                break;
            }
        }
コード例 #4
0
        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);
        }