Ejemplo n.º 1
0
        public static BaseNode CreateNode(String nodeType, String nodeName)
        {
            BaseNode  newNode   = null;
            NodeTypes eNodeType = NodeTypes.nodeNode;

            if (GetNodeType(nodeType, ref eNodeType))
            {
                switch (eNodeType)
                {
                case NodeTypes.nodeNode:
                    newNode = new BaseNode(nodeName);
                    break;

                case NodeTypes.mirrorNode:
                    newNode = new MirrorNode(nodeName);
                    break;

                case NodeTypes.boolNode:
                    newNode = new BoolNode(nodeName);
                    break;

                case NodeTypes.uint16Node:
                    newNode = new UInt16Node(nodeName);
                    break;

                case NodeTypes.uint32Node:
                    newNode = new UInt32Node(nodeName);
                    break;

                case NodeTypes.int32Node:
                    newNode = new Int32Node(nodeName);
                    break;

                case NodeTypes.int64Node:
                    newNode = new Int64Node(nodeName);
                    break;

                case NodeTypes.floatNode:
                    newNode = new FloatNode(nodeName);
                    break;

                case NodeTypes.doubleNode:
                    newNode = new DoubleNode(nodeName);
                    break;

                case NodeTypes.pos3D_32fNode:
                    newNode = new Pos3D_32f_Node(nodeName);
                    break;

                case NodeTypes.stringNode:
                    newNode = new StringNode(nodeName);
                    break;

                default:
                    break;
                }
            }
            return(newNode);
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            BaseNode rootNode = new BaseNode("root");
            BaseNode child    = new BaseNode("child");
            BaseNode sibling1 = new BaseNode("sister");
            BaseNode sibling2 = new BaseNode("brother1");
            BaseNode sibling3 = new BaseNode("brother2");

            rootNode.AddChild(child);
            rootNode.AddChild(sibling1);
            rootNode.AddChild(sibling2);
            rootNode.AddChild(sibling3);
            BaseNode grandChild = new BaseNode("grandChild1");

            child.AddChild(grandChild);
            BaseNode grandGrandChild = new BaseNode("grandGrandChild ");

            grandChild.AddChild(grandGrandChild);

            BaseNode tmp = rootNode.FindNode("child/grandChild1");

            tmp = grandChild.FindNode("../..");
            tmp = rootNode.FindNode("si/../ch/gr/..", true);
            tmp = grandChild.FindNode("/brother1");
            tmp = grandChild.FindNode("/wrongNode");
            tmp = grandChild.FindNode("//brother1");

            rootNode.SetFlags("+hide|+logging|persist|query");
            rootNode.SetAttribute(AttributeTypes.flags, "+hide|-logging|persist|-query");
            rootNode.SetAttribute(AttributeTypes.info, "Dette er en test");

            String     tmpStr    = String.Empty;
            UInt16Node int32Node = new UInt16Node("Int32");

            int32Node.SetAttribute(AttributeTypes.value, "123");
            int32Node.SetAttribute(AttributeTypes.range, "[3, 123]");
            int32Node.SetAttribute(AttributeTypes.range, "[-123, 123]");
            int32Node.GetAttribute(AttributeTypes.value, ref tmpStr);
            int32Node.GetAttribute(AttributeTypes.range, ref tmpStr);

            FloatNode floatNode = new FloatNode("float");

            floatNode.SetAttribute(AttributeTypes.value, "123.456");
            floatNode.SetAttribute(AttributeTypes.range, "[-123.456, 654.321]");
            floatNode.GetAttribute(AttributeTypes.value, ref tmpStr);
            floatNode.GetAttribute(AttributeTypes.range, ref tmpStr);

            DoubleNode doubleNode = new DoubleNode("double");

            doubleNode.SetAttribute(AttributeTypes.value, "123.456");
            doubleNode.SetAttribute(AttributeTypes.range, "[-123.456, 654.321]");
            doubleNode.GetAttribute(AttributeTypes.value, ref tmpStr);
            doubleNode.GetAttribute(AttributeTypes.range, ref tmpStr);

            Pos3D_32f_Node posNode = new Pos3D_32f_Node("Pos3D");

            posNode.SetAttribute(AttributeTypes.value, "[1.1, 2.2, 3.3]");
        }