예제 #1
0
 public void Add(int nodeId, LogicNode newNode)
 {
     LogicNode c;
     if (Nodes.TryGetValue(nodeId, out c))
         Nodes[nodeId] = newNode;
     else
         Nodes.Add(nodeId, newNode);
 }
예제 #2
0
        public void ParseXml(XElement data)
        {
            var logicNodes = data.Elements("logicNode").ToList();
            for (var i = 0; i < logicNodes.Count; i++)
            {
                try
                {
                    int id;
                    var idTest = Input.GetAttribute(logicNodes[i], "id");
                    if (string.IsNullOrWhiteSpace(idTest)) id = i; //if no id is supplied use the index
                    else
                    {
                        idTest = idTest.ToUpper();
                        if (idTest[0] >= 'A' && idTest[0] <= 'Z')  //preferred format is A, B, C, etc. to match equation
                            id = idTest[0] - 'A';
                        else if (!int.TryParse(idTest, out id)) //numerical ids are also accepted where 0 = A
                        {
                            if (BoostLog.Instance != null)
                                BoostLog.Instance.WriteEntry(EventLogEntryType.Error,
                                    string.Format("Illegal LogicNode id {0}", idTest), "", Alias);
                            id = i; //in case of error, use index
                        }
                    }
                    var lNode = new LogicNode(Alias, logicNodes[i]);
                    Add(id, lNode);
                }
                catch
                {
                    continue;
                }
            }

            var equation = data.Element("logicEquation");
            Logic = new LogicEquation(Alias, equation, _maxNodeId);
        }
예제 #3
0
 public bool Equals(LogicNode testNode)
 {
     //only compare names if one is provided
     if (!string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(testNode.Name) && !Name.Equals(testNode.Name)) return false;
     if (!Op.Equals(testNode.Op)) return false;
     if (!Nodes[0].Equals(testNode.Nodes[0])) return false;
     return Nodes[1].Equals(testNode.Nodes[1]);
 }