Ejemplo n.º 1
0
        public override EBTResult Tick()
        {
            EBTResult tmpResult = EBTResult.Running;

            IsRunning = true;

            do
            {
                if (!mRepeatForever)
                {
                    ++mCurrentCount;
                }

                if (mCurrentCount > mCount)
                {
                    tmpResult = EBTResult.Success;
                    IsRunning = false;
                    break;
                }

                EBTResult tmpChildResult = ChildNode.Tick();

                if (mEndOnFailure && EBTResult.Failed == tmpChildResult)
                {
                    tmpResult = EBTResult.Failed;
                    IsRunning = false;
                    break;
                }
            } while (false);

            return(tmpResult);
        }
Ejemplo n.º 2
0
    //c indicates where the child's parent is in relation to it
    private void createChild(ShipChromosomeNode n, ChildNode c, ShipController s)
    {
        GameObject g = (GameObject)GameObject.Instantiate(
            Resources.Load(n.isEngine ? Config.ENGINE_PREFAB_LOCATION : Config.HEAVY_BLOCK_PREFAB_LOCATION),
            Vector3.zero,
            Quaternion.identity);

        if (n.isEngine)
        {
            EngineScript engine = g.GetComponent <EngineScript>();
            engine.initialize(s, n.startEngageAngle, n.rangeEngageAngle);
        }

        g.transform.parent        = transform;
        g.transform.localPosition = Vector3.zero;
        g.transform.localRotation = Quaternion.Euler(0, 0, n.relativeRotation);


        Vector3 colliderSize = g.GetComponent <MeshCollider>().bounds.size;

        switch (c)
        {
        case ChildNode.TOP:
            g.transform.localPosition = g.transform.localPosition
                                        + rotateByThisRotation(new Vector3(0, -colliderSize.y, 0));
            break;

        case ChildNode.BOTTOM:
            g.transform.localPosition = g.transform.localPosition
                                        + rotateByThisRotation(new Vector3(0, colliderSize.y, 0));
            break;

        case ChildNode.LEFT:
            g.transform.localPosition = g.transform.localPosition
                                        + rotateByThisRotation(new Vector3(colliderSize.x, 0, 0));
            break;

        case ChildNode.RIGHT:
            g.transform.localPosition = g.transform.localPosition
                                        + rotateByThisRotation(new Vector3(-colliderSize.x, 0, 0));
            break;
        }

        if (Physics.OverlapSphere(g.transform.position,
                                  (colliderSize.y < colliderSize.x
                                        ? colliderSize.y : colliderSize.x) / 2.1f).Length > 1)
        {
            GameObject.Destroy(g);
            return;
        }

        //FixedJoint fixedJoint = g.AddComponent<FixedJoint>();
        //fixedJoint.enableCollision = false;
        //fixedJoint.connectedBody = rigidbody;


        BlockScript b = g.GetComponent <BlockScript>();

        b.initialize(n, s);
    }
Ejemplo n.º 3
0
        private void BuildIndexes(NRefactory.ArrayInitializerExpression initializer, INode currentNodeIndex)
        {
            initializer.Elements.ForEach(e => {
                var childInitializer = e as NRefactory.ArrayInitializerExpression;

                if (childInitializer != null)
                {
                    var newIndex = new ChildNode {
                        ParentNode = currentNodeIndex
                    };

                    newIndex.Root  = currentNodeIndex.Root;
                    newIndex.Index = currentNodeIndex.Nodes.Count;
                    currentNodeIndex.Nodes.Add(newIndex);
                    BuildIndexes(childInitializer, newIndex);
                }
                else
                {
                    var newIndex = new LinqExpressionNode {
                        ParentNode = currentNodeIndex
                    };

                    newIndex.Root  = currentNodeIndex.Root;
                    newIndex.Index = currentNodeIndex.Nodes.Count;
                    currentNodeIndex.Nodes.Add(newIndex);
                    newIndex.Value = e.AcceptVisitor(Visitor, ParentScope);
                }
            });
        }
Ejemplo n.º 4
0
        // evaluate the tree recursively
        private double EvalTree(Node n)
        {
            if (n == null)
            {
                //Console.WriteLine("No expression entered.");
                return(0);
            }
            else
            {
                if (n is ChildNode) // tree only has one const node
                {
                    ChildNode n1 = (ChildNode)n;
                    return(n1.getVal());
                }
                else if (n is VarNode) // tree has one variable node
                {
                    VarNode n2 = (VarNode)n;
                    return(_dict[n2.getVal()]); // return value assigned by user in the dictionary
                }
                else // m_root is a opNode
                {
                    // need to evaluate the tree
                    double       l;
                    double       r;
                    OperatorNode op = (OperatorNode)n;

                    l = EvalTree(op.Left);
                    r = EvalTree(op.Right);
                    return(op.Eval(l, r));
                }
            }
        }
Ejemplo n.º 5
0
            public override void OnResponse(NetState state, RelayInfo info)
            {
                Mobile from = state.Mobile;

                switch (info.ButtonID)
                {
                case 1:
                {
                    if (m_Node.Parent != null)
                    {
                        from.SendGump(new SendToGump(0, from, m_Tree, m_Node.Parent));
                    }

                    break;
                }

                case 2:
                {
                    if (m_Page > 0)
                    {
                        from.SendGump(new SendToGump(m_Page - 1, from, m_Tree, m_Node));
                    }

                    break;
                }

                case 3:
                {
                    if ((m_Page + 1) * EntryCount < m_Node.Children.Length)
                    {
                        from.SendGump(new SendToGump(m_Page + 1, from, m_Tree, m_Node));
                    }

                    break;
                }

                default:
                {
                    int index = info.ButtonID - 4;

                    if (index >= 0 && index < m_Node.Children.Length)
                    {
                        object o = m_Node.Children[index];

                        if (o is ParentNode)
                        {
                            from.SendGump(new SendToGump(0, from, m_Tree, (ParentNode)o));
                        }
                        else
                        {
                            ChildNode n = (ChildNode)o;

                            from.Target = new SendToTarget(n.Location, m_Tree.Map);
                        }
                    }

                    break;
                }
                }
            }
Ejemplo n.º 6
0
    public override void RemoveChild(BTNode aNode)
    {
        int index = ChildNode.IndexOf(aNode);

        _results.RemoveAt(index);
        base.RemoveChild(aNode);
    }
        private static IEnumerable <ChildNode> GetChildrenNodes(IPublishedContent source)
        {
            var pageInfoData  = new List <ChildNode>();
            var childrenNodes = source.Children;

            if (!childrenNodes.HasAny())
            {
                return(pageInfoData);
            }

            foreach (var publishedContent in childrenNodes)
            {
                var isApiRequest = string.Empty.IsApiRequest();

                var url = isApiRequest
                    ? $"/{ApplicationConstants.ApiRoutePrefix}{publishedContent.Url()}"
                    : publishedContent.Url();

                if (publishedContent.ContentType.Alias.Equals(NewsPage.ModelTypeAlias) && isApiRequest)
                {
                    url = url.Replace($"{publishedContent.UrlSegment}", $"{publishedContent.Id}");
                }

                var urlWithDomain = $"{string.Empty.GetUrlWithDomain()}{url}";

                var childNode = new ChildNode
                {
                    Name = publishedContent.Name, Url = url, UrlWithDomain = urlWithDomain
                };

                pageInfoData.Add(childNode);
            }

            return(pageInfoData);
        }
Ejemplo n.º 8
0
        //Выбрать ряды для генерации
        public IEnumerable <SubRows> SelectRows(TablsList dataTabls, SubRows parentRow)
        {
            IEnumerable <SubRows> rows = dataTabls.Tabls[_tablName].SubList;

            rows = _condition == null ? rows : rows.Where(row => _condition.Generate(row).Boolean);
            return(ChildNode == null ? rows : ChildNode.SelectRows(rows));
        }
        /// <summary>
        /// Returns the value of the attribute for the specified child.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="relativePath">The relative path.</param>
        /// <param name="index">The index.</param>
        /// <param name="attributeId">The attribute id.</param>
        /// <returns>The value of the attribute for the specified child.</returns>
        private object GetAttributeValue(
            ChildNode node,
            IList <QualifiedName> relativePath,
            int index,
            uint attributeId)
        {
            if (index >= relativePath.Count)
            {
                if (node.NodeClass == NodeClass.Object && attributeId == Attributes.NodeId)
                {
                    return(node.Value);
                }

                if (node.NodeClass == NodeClass.Variable && attributeId == Attributes.Value)
                {
                    return(node.Value);
                }

                return(null);
            }

            for (int ii = 0; ii < node.Children.Count; ii++)
            {
                if (node.Children[ii].BrowseName == relativePath[index])
                {
                    return(GetAttributeValue(node.Children[ii], relativePath, index + 1, attributeId));
                }
            }

            return(null);
        }
    public static string GetJSON(DataTable dt)
    {
        List <ParentNode> parent = new List <ParentNode>();

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            var  innerRow      = dt.Rows[i]["Parent"];
            var  objParent     = new ParentNode();
            bool alreadyExists = parent.Any(x => x.Parent.Contains(innerRow.ToString()));

            if (alreadyExists)
            {
                continue;
            }

            DataRow[] foundRows = dt.Select("[Parent]='" + innerRow + "'");

            for (int k = 0; k < foundRows.Count(); k++)
            {
                var objChild = new ChildNode();
                objChild.Child = foundRows[k]["Child"].ToString();
                objParent.Child.Add(objChild);
            }

            objParent.Parent = innerRow.ToString();
            parent.Add(objParent);
        }
        JavaScriptSerializer jsonString = new JavaScriptSerializer();

        return(jsonString.Serialize(parent));
    }
Ejemplo n.º 11
0
        public override string?Render()
        {
            Content = ChildNode?.Render();
            Content = Content != null ? $"<h5{GetAttributes()}>{Content}</h5>" : $"<h5{GetAttributes()}></h5>";

            return(Content + SiblingNode?.Render());
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates a snapshot of a node.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="state">The state.</param>
        /// <returns>A snapshot of a node.</returns>
        private ChildNode CreateChildNode(ISystemContext context, BaseInstanceState state)
        {
            ChildNode node = new ChildNode();

            node.NodeClass  = state.NodeClass;
            node.BrowseName = state.BrowseName;

            BaseVariableState variable = state as BaseVariableState;

            if (variable != null)
            {
                if (!StatusCode.IsBad(variable.StatusCode))
                {
                    node.Value = Utils.Clone(variable.Value);
                }
            }

            BaseObjectState instance = state as BaseObjectState;

            if (instance != null)
            {
                node.Value = instance.NodeId;
            }

            node.Children = CreateChildNodes(context, state);

            return(node);
        }
Ejemplo n.º 13
0
 public void SelectChildNode(ChildNode childNode, ushort updateID)
 {
     if (m_NodeDictionary.ContainsKey(new Tuple <uint, ushort>(childNode.Handle, updateID)))
     {
         TreeView.SelectedNode = m_NodeDictionary[new Tuple <uint, ushort>(childNode.Handle, updateID)];
     }
 }
Ejemplo n.º 14
0
        public VyattaConfigObject AddObject(string Parent)
        {
            string[] Split = Parent.Split(new char[] { ':' }, 2);

            foreach (var ChildNode in Children)
            {
                if (ChildNode.GetAttributeString() == Split[0])
                {
                    if (Split.Length == 2)
                    {
                        return(ChildNode.AddObject(Split[1]));
                    }
                    else
                    {
                        return(ChildNode as VyattaConfigObject);
                    }
                }
            }

            var NewNode = new VyattaConfigObject(new VyattaConfigAttribute(Split[0]));

            Children.Add(NewNode);

            if (Split.Length == 2)
            {
                return(NewNode.AddObject(Split[1]));
            }
            else
            {
                return(NewNode);
            }
        }
Ejemplo n.º 15
0
    public override bool Run()
    {
        Transform Dragon = DragonManager.Instance.transform;
        Transform Player = DragonManager.Instance.Player;

        Vector3 Target = (Player.position - Dragon.position).normalized;

        float Dot = Vector3.Dot(Dragon.forward, Target);

        if (Dot >= Mathf.Cos(Mathf.Deg2Rad * 180.0f * 0.5f))
        {
            Vector3 cross  = Vector3.Cross(Dragon.forward, Target);
            float   result = Vector3.Dot(cross, Vector3.up);

            bool IsLeftPowAttack  = BlackBoard.Instance.IsLeftPowAttack;
            bool IsRightPowAttack = BlackBoard.Instance.IsRightPowAttack;
            bool IsTailAttack     = BlackBoard.Instance.IsTailAttack;

            if ((result < 0.0f && !IsRightPowAttack && !IsTailAttack) || IsLeftPowAttack)
            {
                Debug.Log("Left_Pow_Decorator");
                return(ChildNode.Run());
            }
        }
        return(true);
    }
Ejemplo n.º 16
0
 public void addChild(ChildNode c)
 {
     if (child == null)
     {
         child = c;
     }
 }
Ejemplo n.º 17
0
    //c indicates where the child's parent is in relation to it
    public static ShipChromosomeNode generateRandomShip(int d, ChildNode c)
    {
        ShipChromosomeNode root = new ShipChromosomeNode();

        root.depth     = d;
        root.parentPos = c;

        root.isEngine         = Random.Range(0, 2) == 1;
        root.startEngageAngle = Random.Range(0, 360);
        root.rangeEngageAngle = Random.Range(0, 360);
        root.relativeRotation = Random.Range(-Config.MAX_CHILD_ROTATION, Config.MAX_CHILD_ROTATION);


        float f;

        if (root.depth < Config.MAX_SHIP_DEPTH)
        {
            //top
            if (c != ChildNode.TOP)
            {
                f = Random.Range(0.0f, 1.0f);
                if (f <= Config.CHANCE_OF_CHILD_NODE)
                {
                    root.top = ShipChromosomeNode.generateRandomShip(root.depth + 1, ChildNode.BOTTOM);
                }
            }

            //bottom
            if (c != ChildNode.BOTTOM)
            {
                f = Random.Range(0.0f, 1.0f);
                if (f <= Config.CHANCE_OF_CHILD_NODE)
                {
                    root.bottom = ShipChromosomeNode.generateRandomShip(root.depth + 1, ChildNode.TOP);
                }
            }

            //left
            if (c != ChildNode.LEFT)
            {
                f = Random.Range(0.0f, 1.0f);
                if (f <= Config.CHANCE_OF_CHILD_NODE)
                {
                    root.left = ShipChromosomeNode.generateRandomShip(root.depth + 1, ChildNode.RIGHT);
                }
            }

            //right
            if (c != ChildNode.RIGHT)
            {
                f = Random.Range(0.0f, 1.0f);
                if (f <= Config.CHANCE_OF_CHILD_NODE)
                {
                    root.right = ShipChromosomeNode.generateRandomShip(root.depth + 1, ChildNode.LEFT);
                }
            }
        }

        return(root);
    }
Ejemplo n.º 18
0
        public ContentTree GetContentTree()
        {
            ContentTree contentTree = new ContentTree();

            List<Item> contentItems = _itemRepository.GetAll().ToList();

            if (contentItems == null)
                return null;

            ParentNode parentNode = null;

            contentTree.ContentTreeNodes = new List<ParentNode>();

            foreach (Item contentItem in contentItems)
            {

                if (contentItem.IsParentItem)
                {
                    parentNode = new ParentNode();

                    parentNode.IsContentNode = contentItem.ParentItemId.HasValue ? false : true;

                    parentNode.NodeName = contentItem.DisplayName;
                    parentNode.NodeId = contentItem.Id;
                    parentNode.ChildNodes = new List<ChildNode>();
                }

                if (contentItem.IsParentItem)
                {
                    foreach (Item childNode in contentItems)
                    {
                        if (parentNode != null)
                        {
                            if (childNode.ParentItemId.HasValue )
                            {
                                if (childNode.ParentItemId.Value == parentNode.NodeId)
                                {
                                    ChildNode node = new ChildNode();

                                    node.Id = childNode.Id;
                                    node.ParentItemId = childNode.ParentItemId.Value;
                                    node.ItemTypeId = childNode.ItemTypeId;
                                    node.ItemName = childNode.ItemName;
                                    node.DisplayName = childNode.DisplayName;
                                    node.Created = childNode.Created;
                                    node.ContentOwner = childNode.ContentOwner;

                                    parentNode.ChildNodes.Add(node);
                                }
                            }
                        }
                    }

                    contentTree.ContentTreeNodes.Add(parentNode);
                }
            }

            return contentTree;
        }
Ejemplo n.º 19
0
        public override W_BTNode RemoveChild(W_BTNode aNode)
        {
            int index = ChildNode.IndexOf(aNode);

            _results.RemoveAt(index);
            base.RemoveChild(aNode);
            return(this);
        }
Ejemplo n.º 20
0
        //Выбрать ряды для генерации, узел запроса
        public IEnumerable <SubRows> SelectRows(IEnumerable <SubRows> parentRows)
        {
            var rows = parentRows.SelectMany(row => Condition == null
                                                                               ? row.SubList
                                                                               : row.SubList.Where(r => Condition.Generate(r).Boolean));

            return(ChildNode == null ? rows : ChildNode.SelectRows(rows));
        }
Ejemplo n.º 21
0
 private void l_zNumericUpDown_ValueChanged(object sender, EventArgs e)
 {
     if (locationsTreeView.SelectedNode.Tag is ChildNode)
     {
         ChildNode node = locationsTreeView.SelectedNode.Tag as ChildNode;
         node.Z = (int)zNumericUpDown.Value;
     }
 }
Ejemplo n.º 22
0
        //Выбрать ряды для генерации, главный узел выражения подтаблицы
        public IEnumerable <SubRows> SelectRows(TablsList dataTabls, SubRows parentRow)
        {
            IEnumerable <SubRows> rows = Condition == null
                                            ? parentRow.SubList
                                            : parentRow.SubList.Where(row => Condition.Generate(row).Boolean);

            return(ChildNode == null ? rows : ChildNode.SelectRows(rows));
        }
Ejemplo n.º 23
0
 public override bool Run()
 {
     if (DragonManager.Stat.HP <= 0)
     {
         return(ChildNode.Run());
     }
     return(false);
 }
Ejemplo n.º 24
0
 private void locationsTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Node.Tag is ChildNode)
     {
         ChildNode node = e.Node.Tag as ChildNode;
         SetLocation(node.Map, node.X, node.Y, node.Z);
     }
 }
Ejemplo n.º 25
0
        public override int GetHashCode()
        {
            var guid = ChildNode.GetOptionalStringAttribute("guid", string.Empty);

            return((guid == string.Empty)
                                ? base.GetHashCode()
                                : guid.ToLowerInvariant().GetHashCode());
        }
Ejemplo n.º 26
0
 private void l_mapComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (locationsTreeView.SelectedNode.Tag is ChildNode)
     {
         ChildNode node = locationsTreeView.SelectedNode.Tag as ChildNode;
         node.Map = (Maps)mapComboBox.SelectedIndex;
     }
 }
Ejemplo n.º 27
0
 public void Sort()
 {
     ChildNodes = ChildNodes.OrderBy(x => x.Record.Name).ToList();
     foreach (StreamNode ChildNode in ChildNodes)
     {
         ChildNode.Sort();
     }
 }
Ejemplo n.º 28
0
 //you would use this instead of (Nodes.Remove)
 public void RemoveNode(ChildNode node)
 {
     if (ChildNodes.Contains(node))
     {
         node.ParentNode = null;
         ChildNodes.Remove(node);
         PopulateChildren();
     }
 }
Ejemplo n.º 29
0
 //you would use this instead of (Nodes.Add)
 public void AddNode(ChildNode node)
 {
     if (!ChildNodes.Contains(node))
     {
         node.ParentNode = this;
         ChildNodes.Add(node);
         PopulateChildren();
     }
 }
        /// <summary>
        /// Returns a clone of the node of this state.
        /// </summary>
        /// <returns>The cloned node.</returns>
        public override INode CloneNode()
        {
            INode NewNode = null;

            NodeTreeHelperOptional.GetChildNode(Optional, out bool IsAssigned, out INode ChildNode);
            if (ChildNode != null)
            {
                // Create a clone, initially empty and full of null references.
                NewNode = NodeHelper.CreateEmptyNode(ChildNode.GetType());

                // Clone and assign reference to all nodes, optional or not, list and block lists.
                foreach (KeyValuePair <string, IReadOnlyInner> Entry in InnerTable)
                {
                    string         PropertyName = Entry.Key;
                    IReadOnlyInner Inner        = Entry.Value;
                    ((IReadOnlyInner <IReadOnlyBrowsingChildIndex>)Inner).CloneChildren(NewNode);
                }

                // Copy other properties.
                foreach (KeyValuePair <string, ValuePropertyType> Entry in ValuePropertyTypeTable)
                {
                    string            PropertyName = Entry.Key;
                    ValuePropertyType Type         = Entry.Value;
                    bool IsHandled = false;

                    switch (Type)
                    {
                    case ValuePropertyType.Boolean:
                        NodeTreeHelper.CopyBooleanProperty(Node, NewNode, Entry.Key);
                        IsHandled = true;
                        break;

                    case ValuePropertyType.Enum:
                        NodeTreeHelper.CopyEnumProperty(Node, NewNode, Entry.Key);
                        IsHandled = true;
                        break;

                    case ValuePropertyType.String:
                        NodeTreeHelper.CopyStringProperty(Node, NewNode, Entry.Key);
                        IsHandled = true;
                        break;

                    case ValuePropertyType.Guid:
                        NodeTreeHelper.CopyGuidProperty(Node, NewNode, Entry.Key);
                        IsHandled = true;
                        break;
                    }

                    Debug.Assert(IsHandled);
                }

                // Also copy comments.
                NodeTreeHelper.CopyDocumentation(Node, NewNode, cloneCommentGuid: true);
            }

            return(NewNode);
        }
Ejemplo n.º 31
0
        public void ChildReferencingParentTest()
        {
            ParentNode parent = new ParentNode();
            ChildNode child = new ChildNode();

            parent.Children.Add(child);
            Assert.AreSame(parent, child.Parent);

            parent.Children.Remove(child);
            Assert.IsNull(child.Parent);
        }
Ejemplo n.º 32
0
        public void ChildReferencingParentTest()
        {
            ParentNode parent = new ParentNode();
            ChildNode child1 = new ChildNode();
            ChildNode child2 = new ChildNode();

            parent.AdoptedChildren.Add(child1);
            parent.AdoptedChildren.Add(child2);
            Assert.AreSame(parent, child1.Parent);
            Assert.AreSame(parent, child2.Parent);

            Assert.AreSame(child1, parent.AdoptedChildren[0]);
            Assert.AreSame(child2, parent.AdoptedChildren[1]);

            parent.AdoptedChildren.Remove(child1);
            Assert.IsNull(child1.Parent);
            Assert.AreSame(parent, child2.Parent);
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Returns the value of the attribute for the specified child.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="relativePath">The relative path.</param>
        /// <param name="index">The index.</param>
        /// <param name="attributeId">The attribute id.</param>
        /// <returns>The value of the attribute for the specified child.</returns>
        private object GetAttributeValue(
            ChildNode node,
            IList<QualifiedName> relativePath,
            int index, 
            uint attributeId)
        {
            if (index >= relativePath.Count)
            {
                if (node.NodeClass == NodeClass.Object && attributeId == Attributes.NodeId)
                {
                    return node.Value;
                }

                if (node.NodeClass == NodeClass.Variable && attributeId == Attributes.Value)
                {
                    return node.Value;
                }

                return null;
            }

            for (int ii = 0; ii < node.Children.Count; ii++)
            {
                if (node.Children[ii].BrowseName == relativePath[index])
                {
                    return GetAttributeValue(node.Children[ii], relativePath, index+1, attributeId);
                }
            }

            return null;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Creates a snapshot of a node.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="state">The state.</param>
        /// <returns>A snapshot of a node.</returns>
        private ChildNode CreateChildNode(ISystemContext context, BaseInstanceState state)
        {
            ChildNode node = new ChildNode();

            node.NodeClass  = state.NodeClass;
            node.BrowseName = state.BrowseName;

            BaseVariableState variable = state as BaseVariableState;

            if (variable != null)
            {
                if (!StatusCode.IsBad(variable.StatusCode))
                {
                    node.Value = Utils.Clone(variable.Value);
                }
            }

            BaseObjectState instance = state as BaseObjectState;

            if (instance != null)
            {
                node.Value = instance.NodeId;                    
            }

            node.Children = CreateChildNodes(context, state);

            return node;
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Sets the value for a child. Adds it if it does not already exist.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="browseName">The BrowseName.</param>
        /// <param name="nodeClass">The node class.</param>
        /// <param name="value">The value.</param>
        private void SetChildValue(
            ChildNode node,
            QualifiedName browseName,
            NodeClass nodeClass,
            object value)
        {
            ChildNode child = null;

            if (node.Children != null)
            {
                for (int ii = 0; ii < node.Children.Count; ii++)
                {
                    child = node.Children[ii];

                    if (child.BrowseName == browseName)
                    {
                        break;
                    }

                    child = null;
                }
            }
            else
            {
                node.Children = new List<ChildNode>();
            }

            if (child == null)
            {
                child = new ChildNode();
                node.Children.Add(child);
            }

            child.BrowseName = browseName;
            child.NodeClass = nodeClass;
            child.Value = value;
        }