public void AddSymbol(PlcSymbol symbol)
 {
     if (this.Symbols.All(x => x.Name != symbol.Name))
     {
         this.Symbols.Add(symbol);
     }
 }
 public static void MapToTree(IEnumerable <ClassTree> trees, PlcSymbol symbol)
 {
     foreach (var classTree in trees)
     {
         var nodeToAddTo = classTree.FindNode(symbol.Name);
         if (nodeToAddTo != null)
         {
             nodeToAddTo.AddSymbol(symbol);
             return;
         }
     }
 }
            public static IEnumerable <PlcType> ReadTypes(string path)
            {
                var xml       = XDocument.Load(path);
                var dataTypes = xml.Root.Descendants(XName.Get("DataTypes"));

                var types = new List <PlcType>();

                foreach (var dataType2 in dataTypes)
                {
                    var dataTypes2 = dataType2.Descendants(XName.Get("DataType"));
                    foreach (var dataType in dataTypes2)
                    {
                        var type = new PlcType(dataType.Element("Name").Value);
                        foreach (var symbol in dataType.Descendants(XName.Get("SubItem")))
                        {
                            var arrInfos = symbol.Descendants(XName.Get("ArrayInfo"));
                            List <ArrayInfo> arrInfoList = null;
                            if (arrInfos.Any())
                            {
                                arrInfoList = new List <ArrayInfo>();
                                foreach (var arrInfo in arrInfos)
                                {
                                    arrInfoList.Add(
                                        new ArrayInfo(int.Parse(arrInfo.Element("LBound").Value),
                                                      int.Parse(arrInfo.Element("Elements").Value)));
                                }
                            }

                            var parsedSymbol = new PlcSymbol(symbol.Element("Name").Value,
                                                             new PlcType(symbol.Element("Type").Value),
                                                             int.Parse(symbol.Element("BitSize").Value), int.Parse(symbol.Element("BitOffs").Value),
                                                             arrInfoList);

                            type.AddSymbol(parsedSymbol);
                        }

                        types.Add(type);
                    }
                }

                var nestedTypes = new List <PlcType>();

                foreach (var plcType in types)
                {
                    nestedTypes.Add(GetFlattenedType(plcType));
                }

                return(nestedTypes);
            }
 public void AddSymbol(PlcSymbol symbol)
 {
     this.Symbols.Add(symbol);
 }