Пример #1
0
 private void BuildParentEntityNodes()
 {
     NodeMap.Add("ContractType",
                 new EngineNodeHolder(EngineNode: null, EngineNodeOptions.CallbackValue, "Lease"));
     NodeMap.Add("LegalEntity.Name",
                 new EngineNodeHolder(EngineNode: "_Customer"));
     NodeMap.Add("Customer.Party.PartyName",
                 new EngineNodeHolder(EngineNode: "_ShipContact", EngineNodeOptions.LinePosition, "2"));
     NodeMap.Add("Vendor.Party.PartyName",
                 new EngineNodeHolder(EngineNode: "_CompanyName1"));
     NodeMap.Add("InvoiceNumber",
                 new EngineNodeHolder(EngineNode: "_DocumentRef"));
     NodeMap.Add("Alias",
                 new EngineNodeHolder(EngineNode: "_CallRef"));
     NodeMap.Add("InvoiceDate",
                 new EngineNodeHolder(EngineNode: "_Date", EngineNodeOptions.Date));
     NodeMap.Add("DueDate",
                 new EngineNodeHolder(EngineNode: "_Date", EngineNodeOptions.Date));
     NodeMap.Add("Currency.Name",
                 new EngineNodeHolder(EngineNode: null, EngineNodeOptions.CallbackValue, "ZAR"));
     NodeMap.Add("ContractCurrency.Name",
                 new EngineNodeHolder(EngineNode: null, EngineNodeOptions.CallbackValue, "ZAR"));
     NodeMap.Add("InvoiceTotal",
                 new EngineNodeHolder(EngineNode: "_Total", EngineNodeOptions.NodePosition, "10"));
     NodeMap.Add("NumberOfAssets",
                 new EngineNodeHolder(EngineNode: "_LineItems", EngineNodeOptions.NodeCount));
     NodeMap.Add("AllowCreateAssets",
                 new EngineNodeHolder(EngineNode: null, EngineNodeOptions.CallbackValue, "true"));
 }
Пример #2
0
        /// <summary>
        /// Removes a node and all of its edges. If the node doesn't exist, nothing happens.
        /// </summary>
        /// <param name="node">node reference</param>
        public virtual void RemoveNode(Node node)
        {
            if (node == null || !NodeMap.ContainsKey(node.Id))
            {
                return;
            }
            var delendi = new ArrayList();

            foreach (Edge e in node.InEdges)
            {
                delendi.Add(e);
            }
            foreach (Edge e in node.OutEdges)
            {
                delendi.Add(e);
            }
            foreach (Edge e in node.SelfEdges)
            {
                delendi.Add(e);
            }
            foreach (Edge e in delendi)
            {
                RemoveEdge(e);
            }
            NodeMap.Remove(node.Id);
            GeometryGraph.Nodes.Remove(node.GeometryObject as Core.Layout.Node);
        }
Пример #3
0
        public void DestroyBoard(bool playSound = true)
        {
            if (_gameBoard == null)
            {
                return;
            }

            // Destroy the lattice grid
            _lattice.DestroyGrid();

            // Destroy all objects in the game board
            var i = 0;

            foreach (var node in NodeMap.Values)
            {
                node.WaveOut(i++, NodeMap.Count, playSound: playSound);
            }

            foreach (var field in FieldMap.Fields)
            {
                field.Highlight(false);
            }

            foreach (Transform child in transform)
            {
                var node  = child.gameObject.GetComponent <NodeView>();
                var arc   = child.gameObject.GetComponent <ArcView>();
                var field = child.gameObject.GetComponent <FieldView>();

                // Only destroy board pieces
                if (node != null)
                {
                    _itemPool.Release(node, 3f);
                }
                else if (arc != null)
                {
                    _itemPool.Release(arc, 3f);
                }
                else if (field != null)
                {
                    _itemPool.Release(field, 3f);
                }
            }

            NodeMap.Clear();
            ArcMap.Clear();
            FieldMap.Clear();

            _gameBoard = null;

            if (!playSound)
            {
                return;
            }

            // TODO: make configurable
            const float volume = 0.5f;

            _gameAudio.Play(GameClip.GameEnd, volume: volume);
        }
Пример #4
0
        protected void ClearNodeCache(TreeNode node)
        {
            if (node == null)
            {
                return;
            }

            if (node.Tag is Guid)
            {
                Guid uid = (Guid)node.Tag;
                if (NodeMap.ContainsKey(uid))
                {
                    NodeMap[uid].Remove(node);
                    if (NodeMap[uid].Count == 0)
                    {
                        NodeMap.Remove(uid);
                    }
                }
            }

            foreach (TreeNode subNode in node.Nodes)
            {
                ClearNodeCache(subNode);
            }
        }
Пример #5
0
        private List <NodeMap> GetNextLayerNodes(List <NodeMap> prevLayerNodes, IReadOnlyList <IConnectionGene> innerConnections)
        {
            var connectionNodes = innerConnections
                                  .Where(c =>
            {
                return(prevLayerNodes.FirstOrDefault(n => n.NeuronId == c.SourceNodeIdx) != null);
            })
                                  .Select(c => c)
                                  .GroupBy(c => c.TargetNodeIdx)
                                  .ToList();

            List <NodeMap> nextNodeLayer = new List <NodeMap>(connectionNodes.Count);

            foreach (var connectionNode in connectionNodes)
            {
                var netMapNode = _netMap.Keys.FirstOrDefault(n => n.NeuronId == connectionNode.Key);

                if (netMapNode == null)
                {
                    var nodeMap = new NodeMap(_nextNetNodeId, connectionNode.Key);

                    _netMap.Add(nodeMap, new List <INetConnection>());
                    nextNodeLayer.Add(nodeMap);

                    _nextNetNodeId++;
                }
            }

            return(nextNodeLayer);
        }
Пример #6
0
        public void Test19_1_ポインタの加算と減算()
        {
            // TODO: 現状は全ての変数をスタックに 8byte ずつ積んでいるので成立する
            var src       = @"
int main() {
    int a;
    int b;
    int c;
    int d;
    d = 1;
    c = 2;
    b = 4;
    a = 8;
    int *p;
    int *q;
    p = &d;
    q = p + 3;
    return *q;
}
";
            var tokenList = TokenList.Tokenize(src);
            var nodeMap   = NodeMap.Create(tokenList);

            Assert.IsTrue(ValidateNodeValuesAndOffsets(nodeMap));

            Assert.AreEqual(8, CopmlileAndExecOnWsl(src));
        }
Пример #7
0
    /// <summary>
    /// 正面のノードを計算する
    /// </summary>
    /// <returns></returns>
    public static string FrontNode(NodeMap nodeMap, string current, string next)
    {
        var nodes = nodeMap.nodeMap;
        // current node を除く
        var n = nodes[next].Graph.Where(name => name != current).ToList();

        if (n.Count > 0)
        {
            n.Sort((a, b) =>
            {
                var cpos = nodes[current].Position;
                var npos = nodes[next].Position;
                var apos = nodes[a].Position;
                var bpos = nodes[b].Position;
                var ad   = Vector3.Dot((npos - cpos).normalized, (apos - npos).normalized);
                var bd   = Vector3.Dot((npos - cpos).normalized, (bpos - npos).normalized);
                return(bd.CompareTo(ad));
            });
            return(n[0]);
        }
        else
        {
            return(current);
        }
    }
Пример #8
0
        public void Test10_if文()
        {
            var src       = @"
int main() {
    if ( 1 )
        return 2;
    else
        return 3;
}
";
            var tokenList = TokenList.Tokenize(src);
            var nodeMap   = NodeMap.Create(tokenList);

            Assert.IsTrue(ValidateNodeValuesAndOffsets(nodeMap));
            var block = nodeMap.Head.Nodes.Item1;

            Assert.AreEqual(1, block.Bodies.Count);
            var n0 = block.Bodies[0];

            Assert.AreEqual(NodeKind.If, n0.Kind);
            Assert.AreEqual(1, n0.Condition.Value);
            Assert.AreEqual(NodeKind.Return, n0.Nodes.Item1.Kind);
            Assert.AreEqual(2, n0.Nodes.Item1.Nodes.Item1.Value);
            Assert.AreEqual(NodeKind.Return, n0.Nodes.Item2.Kind);
            Assert.AreEqual(3, n0.Nodes.Item2.Nodes.Item1.Value);

            Assert.AreEqual(2, CopmlileAndExecOnWsl(src));
        }
Пример #9
0
        public void Test09_return文()
        {
            var src       = @"
int main() {
    int abc;
    abc = 15;
    return abc;
}
";
            var tokenList = TokenList.Tokenize(src);
            var nodeMap   = NodeMap.Create(tokenList);

            Assert.IsTrue(ValidateNodeValuesAndOffsets(nodeMap));
            var block = nodeMap.Head.Nodes.Item1;

            Assert.AreEqual(3, block.Bodies.Count);
            var n0 = block.Bodies[1];
            var n1 = block.Bodies[2];

            Assert.AreEqual(NodeKind.Assign, n0.Kind);
            Assert.AreEqual(8, n0.Nodes.Item1.Offset);
            Assert.AreEqual(15, n0.Nodes.Item2.Value);
            Assert.AreEqual(NodeKind.Return, n1.Kind);
            Assert.AreEqual(8, n1.Nodes.Item1.Offset);
            Assert.IsNull(n1.Nodes.Item2);

            Assert.AreEqual(15, CopmlileAndExecOnWsl(src));
        }
Пример #10
0
        public void Test08_複数文字のローカル変数()
        {
            var src       = @"
int main() {
    int foo;
    int bar;
    foo = 1;
    bar = 2 + 3;
    foo + bar;
}
";
            var tokenList = TokenList.Tokenize(src);
            var nodeMap   = NodeMap.Create(tokenList);

            Assert.IsTrue(ValidateNodeValuesAndOffsets(nodeMap));
            var block = nodeMap.Head.Nodes.Item1;

            Assert.AreEqual(block.Bodies.Count, 5);
            var n0 = block.Bodies[2];
            var n1 = block.Bodies[3];
            var n2 = block.Bodies[4];

            Assert.AreEqual(8, n0.Nodes.Item1.Offset);
            Assert.AreEqual(1, n0.Nodes.Item2.Value);
            Assert.AreEqual(16, n1.Nodes.Item1.Offset);
            Assert.AreEqual(NodeKind.Add, n1.Nodes.Item2.Kind);
            Assert.AreEqual(2, n1.Nodes.Item2.Nodes.Item1.Value);
            Assert.AreEqual(3, n1.Nodes.Item2.Nodes.Item2.Value);
            Assert.AreEqual(NodeKind.Add, n2.Kind);
            Assert.AreEqual(8, n2.Nodes.Item1.Offset);
            Assert.AreEqual(16, n2.Nodes.Item2.Offset);

            Assert.AreEqual(6, CopmlileAndExecOnWsl(src));
        }
Пример #11
0
        public void Solve()
        {
            NodeMap <Nodes> nodeMap       = new NodeMap <Nodes>(mazeNodes, nodeConnections);
            QueueSearcher   queueSearcher = new QueueSearcher();
            Nodes           startingNode  = null;
            Nodes           endingNode    = null;

            foreach (Nodes node in mazeNodes)
            {
                if (node.StartingPoint)
                {
                    startingNode = node;
                }
                else if (node.FinishingPoint)
                {
                    endingNode = node;
                }
            }
            var    shortestPath   = queueSearcher.ShortestPath(nodeMap, startingNode);
            string returnedString = string.Join(", ", shortestPath(endingNode));

            if (returnedString != "")
            {
                Console.WriteLine("Maze Solution: {0}", returnedString);
            }
            else
            {
                Console.WriteLine("Maze cannot be solved");
            }
        }
        public IActionResult Get(string id, string start, string end)
        {
            NodeMap item = null;

            item = _context.MapsDB.FirstOrDefault(t => t.ID == id);
            if (item == null)
            {
                return(NotFound("Map ID not found"));
            }
            bool validStart = item.allNodes.ContainsKey(start);
            bool validEnd   = item.allNodes.ContainsKey(end);

            if (!validStart || !validEnd)
            {
                return(NotFound("Start or end ID not found!"));
            }
            Node testNode  = item.allNodes[start];
            Node testnode2 = item.allNodes["e"];
            BestPathDirections returnObjectUnserialized =
                item.getBestPath(item.allNodes[start], item.allNodes[end]);
            string jsonTestSer = JsonConvert.SerializeObject(returnObjectUnserialized);

            return(new ObjectResult(returnObjectUnserialized));
            //now that we have the result...
        }
Пример #13
0
 public void CopyToModel(NodeMap nodeMap)
 {
     lock (_modelLock)
     {
         Model.CopyFrom(nodeMap);
     }
 }
Пример #14
0
    private void Start()
    {
        //create map
        map = new NodeMap();
        map.defaultNodeGraphic       = defaultSprite;
        map.defaultUnpathableGraphic = unpathableSprite;
        map.Initialize(WIDTH, HEIGHT, SIZE);

        //set unpathable nodes
        map.SetPathingAt(2, 1, false);
        map.SetPathingAt(2, 2, false);
        map.SetPathingAt(2, 3, false);
        map.SetPathingAt(3, 3, false);
        map.SetPathingAt(4, 3, false);
        map.SetPathingAt(5, 3, false);
        map.SetPathingAt(6, 3, false);
        map.SetPathingAt(7, 3, false);
        map.SetPathingAt(7, 2, false);
        map.SetPathingAt(7, 1, false);
        map.SetPathingAt(7, 0, false);

        //create and place character
        if (characterSprite)
        {
            character         = new NodeOccupant();
            character.graphic = (GameObject)Instantiate(characterSprite, new Vector3(0, 0, 0), Quaternion.identity);
            map.SetNodeOccupantAt(1, 1, character);
        }

        map.Build();
        map.OnNodeClicked += OnNodeClicked;
    }
Пример #15
0
 /// <summary>
 /// This is used to serialize a representation of the object value
 /// provided. If there is a <c>Registry</c> binding present
 /// for the provided type then this will use the converter specified
 /// to serialize a representation of the object. If however there
 /// is no binding present then this will delegate to the internal
 /// strategy. This returns true if the serialization has completed.
 /// </summary>
 /// <param name="type">
 /// this is the type that represents the field or method
 /// </param>
 /// <param name="value">
 /// this is the object instance to be serialized
 /// </param>
 /// <param name="node">
 /// this is the XML element to be serialized to
 /// </param>
 /// <param name="map">
 /// this is the session map used by the serializer
 /// </param>
 /// <returns>
 /// this returns true if it was serialized, false otherwise
 /// </returns>
 public bool Write(Type type, Object value, NodeMap<OutputNode> node, Dictionary map) {
    bool reference = strategy.Write(type, value, node, map);
    if(!reference) {
       return Write(type, value, node);
    }
    return reference;
 }
Пример #16
0
        public void Test07_1文字変数()
        {
            var src       = @"
int main() {
    int a;
    int z;
    a = 10;
    z = 50;
    a = z + a;
}
";
            var tokenList = TokenList.Tokenize(src);
            var nodeMap   = NodeMap.Create(tokenList);

            Assert.IsTrue(ValidateNodeValuesAndOffsets(nodeMap));
            var block = nodeMap.Head.Nodes.Item1;

            Assert.AreEqual(5, block.Bodies.Count);
            var n0 = block.Bodies[2];
            var n1 = block.Bodies[3];
            var n2 = block.Bodies[4];

            Assert.AreEqual(8, n0.Nodes.Item1.Offset);
            Assert.AreEqual(10, n0.Nodes.Item2.Value);
            Assert.AreEqual(16, n1.Nodes.Item1.Offset);
            Assert.AreEqual(50, n1.Nodes.Item2.Value);
            Assert.AreEqual(8, n2.Nodes.Item1.Offset);
            Assert.AreEqual(NodeKind.Add, n2.Nodes.Item2.Kind);
            Assert.AreEqual(16, n2.Nodes.Item2.Nodes.Item1.Offset);
            Assert.AreEqual(8, n2.Nodes.Item2.Nodes.Item2.Offset);

            Assert.AreEqual(60, CopmlileAndExecOnWsl(src));
        }
Пример #17
0
    private void Start()
    {
        // To "Bake" the node map to capture untraversable areas. Whill scan the each node on wallTileMap for untraversable tiles on nodeMap
        nodeMap.BakeBlockedMap(wallTileMap);

        // Baking traversable but not desirable areas with 1.5 cost
        nodeMap.BakeCostMap(LayerMask.GetMask("Water"), 1.5f);

        /*
         * For 3D map baking
         *
         * Overloaded method, takes integer repersenting LayerMask id for *IGNORED* physics layer
         *
         * Scans each node with Physics.CheckSphere() for colliders around node, any collider detected not in above mentioned LayerMask will be consider an obstacle.
         * Therefore, marking that node as untraversable.
         */

        // nodeMap.BakeBlockedMap(LayerMask.GetMask("Ignore Raycast"));


        // Save baked map as "MyNodeMap.bin" at ../UnityProjectFile/Assets/MyNodeMap.bin
        nodeMap.Save("MyNodeMap");

        // Load baked map from ../UnityProjectFile/Assets/MyNodeMap.bin
        nodeMap = NodeMap.Load("MyNodeMap");
    }
Пример #18
0
 /// <summary>
 /// This is used to read the <c>Value</c> which will be used
 /// to represent the deserialized object. If there is an binding
 /// present then the value will contain an object instance. If it
 /// does not then it is up to the internal strategy to determine
 /// what the returned value contains.
 /// </summary>
 /// <param name="type">
 /// this is the type that represents a method or field
 /// </param>
 /// <param name="node">
 /// this is the node representing the XML element
 /// </param>
 /// <param name="map">
 /// this is the session map that contain variables
 /// </param>
 /// <returns>
 /// the value representing the deserialized value
 /// </returns>
 public Value Read(Type type, NodeMap<InputNode> node, Dictionary map) {
    Value value = strategy.Read(type, node, map);
    if(IsReference(value)) {
       return value;
    }
    return Read(type, node, value);
 }
Пример #19
0
        /// <summary>
        /// Rebuilds the tree from scratch.
        /// </summary>
        public void RebuildTree()
        {
            // store old tree state
            List <string> previouslyExpanded = ExpandedPaths;
            Point         scrollPos          = Win32.Scrolling.GetScrollPos(this);
            string        currentPath        = SelectedNode != null ? SelectedNode.BackingPath : null;

            try
            {
                BeginUpdate();
                BuildTree();

                // BUG: avoid nodes expansion to generate redraws
                EndUpdate();
                BeginUpdate();

                // restore tree state
                ExpandedPaths = previouslyExpanded;
                if (currentPath != null && NodeMap.ContainsKey(currentPath))
                {
                    SelectedNode = NodeMap[currentPath];
                }
                else
                {
                    SelectedNode = Nodes[0] as GenericNode;// projectNode;
                }
            }
            finally
            {
                EndUpdate();
                Win32.Scrolling.SetScrollPos(this, scrollPos);
            }
        }
Пример #20
0
        private string SelectXmlNodes(string[] NodesToBeIterated)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var nodetobeiterated in NodesToBeIterated)
            {
                using (StringReader s = new StringReader(cleanEngineXmlString))
                {
                    XDocument xdoc       = XDocument.Load(s);
                    var       childnodes = xdoc.Descendants(nodetobeiterated).ToArray();
                    foreach (var childnode in childnodes)
                    {
                        var child =
                            new XElement("PayableInvoiceAsset",
                                         NodeMap.Where(keyvaluePair => !keyvaluePair.Value.IsParentAttribute &&
                                                       keyvaluePair.Value.engineNodeOptions != EngineNodeOptions.ChildEntityPointer)
                                         .Select(keyvaluePair => new XElement(keyvaluePair.Key,
                                                                              XmlHelperInstance.FetchValueFromNodeForChild(NodeMap.GetValueOrDefault(keyvaluePair.Key), childnode))
                                                 )
                                         );
                        sb.Append(child.ConvertToString());
                    }
                }
            }
            return(sb.ToString());
        }
    public async void WaitForActiveNodeMaps(NodeMap map)
    {
        await ToSignal(map, "finished");

        activeNodeMaps[map] = false;
        CheckActiveNodeMaps();
    }
Пример #22
0
 public Project(int width, int height, int frequency)
 {
     this.projectWidth  = width;
     this.projectHeight = height;
     this.geoFrequency  = frequency;
     map = new NodeMap();
 }
Пример #23
0
        public HashSet <T> BFSearch <T>(NodeMap <T> nodeMap, T rootNode)
        {
            HashSet <T> visitedNodes = new HashSet <T>();

            if (!nodeMap.ConnectingList.ContainsKey(rootNode))
            {
                return(visitedNodes);
            }

            Queue <T> queue = new Queue <T>();

            queue.Enqueue(rootNode);

            while (queue.Count > 0)
            {
                var nodeVertex = queue.Dequeue();

                if (visitedNodes.Contains(nodeVertex))
                {
                    continue;
                }

                visitedNodes.Add(nodeVertex);

                foreach (T neighborNode in nodeMap.ConnectingList[nodeVertex])
                {
                    if (!visitedNodes.Contains(neighborNode))
                    {
                        queue.Enqueue(neighborNode);
                    }
                }
            }

            return(visitedNodes);
        }
Пример #24
0
 public SettingInfo(OryxSettingName settingName, NodeType nodeType, NodeMap nodeMap, string value)
 {
     _SettingName = settingName;
     _NodeType    = nodeType;
     _NodeMap     = nodeMap;
     _Value       = value;
 }
        public IActionResult Put(string id, [FromBody] string value)
        {
            if (value == null || !value.Contains("nodes"))
            {
                return(BadRequest());
            }
            IncomingNodeListJSON testing = JsonConvert.DeserializeObject <IncomingNodeListJSON>(value);

            testing.ID = id;
            NodeMap nodeMap = new NodeMap(id);

            foreach (string name in testing.nodes.Keys)
            {
                Node n = new Node(name);
                foreach (var pair in testing.nodes[name])
                {
                    n.nodeDictionary.Add(pair.Key, pair.Value);
                }
                _context.MapsDB.Add(nodeMap);
                _context.SaveChanges();

                Console.WriteLine("PUT ID: {0}", id);
                Console.WriteLine(testing);
                return(Ok());
            }
            return(BadRequest());
        }
    public async void Intro()
    {
        Control root = GetNode("Intro") as Control;

        root.SetVisible(true);

        Tween tween = new Tween();

        AddChild(tween);

        /*
         * Label label = root.GetNode("Title") as Label;
         * await ToSignal(this, "next");
         * label.SetVisible(true);
         * tween = CommonTweenUtil.Fade(label, 0.3f, 0, 1, tween);
         * tween.Start();
         * await ToSignal(tween, "tween_completed");
         */

        NodeMap maze = root.GetNode("NodeMap") as NodeMap;

        // set maze size
        maze.SetHeight(79);
        maze.SetWidth(159);
        maze.ResizeBlock();
        //maze.animate = false;

        await ToSignal(this, "next");

        maze.SetVisible(true);
        tween = CommonTweenUtil.Fade(maze, 0.3f, 0, 1, tween);
        //tween = CommonTweenUtil.Scale(maze, new Vector2(0, 0), new Vector2(1, 1), 0.3f, tween);
        tween.Start();
        await ToSignal(tween, "tween_completed");

        await ToSignal(this, "next");

        maze.GenerateMap();
        await ToSignal(maze, "finished");

        maze.SetDst(159 * 2 - 2);

        await ToSignal(this, "next");

        maze.AStar();
        await ToSignal(maze, "finished");

        await ToSignal(this, "next");

        tween.RemoveAll();
        tween = CommonTweenUtil.Fade(root, 0.3f, 1, 0, tween);
        tween.Start();
        await ToSignal(tween, "tween_completed");

        tween.QueueFree();
        root.SetVisible(false);

        EmitSignal("section_finished");
    }
Пример #27
0
 public AStar(Vector2Int _start, Vector2Int _end, NodeMap _map /*,PathFinder _finder*/)
 {
     start = _map.GetNodeByGridPos(_start.x, _start.y);
     end   = _map.GetNodeByGridPos(_end.x, _end.y);
     now   = start;
     map   = _map;
     //finder = _finder;
 }
Пример #28
0
		public Signal(NodeMap<LocalNode> locals, NodeMap<RemoteNode> remotes)
		{
			this.Locals = locals;
			this.Remotes = remotes;
			this.Signature = "";
			this.Funcs = new List<Function>();
			this.Context = new SignalContext();
		}
Пример #29
0
 /// <summary>
 /// This method will read with  an internal strategy after it has
 /// been intercepted by the visitor. Interception of the XML node
 /// before it is delegated to the internal strategy allows the
 /// visitor to change some attributes or details before the node
 /// is interpreted by the strategy.
 /// </summary>
 /// <param name="type">
 /// this is the type of the root element expected
 /// </param>
 /// <param name="node">
 /// this is the node map used to resolve an override
 /// </param>
 /// <param name="map">
 /// this is used to maintain contextual information
 /// </param>
 /// <returns>
 /// the value that should be used to describe the instance
 /// </returns>
 public Value Read(Type type, NodeMap <InputNode> node, Dictionary map)
 {
     if (visitor != null)
     {
         visitor.Read(type, node);
     }
     return(strategy.Read(type, node, map));
 }
Пример #30
0
 public Project()
 {
     //Default values for project resoultion
     this.projectWidth  = 640;
     this.projectHeight = 480;
     this.geoFrequency  = 4;
     map = new NodeMap();
 }
Пример #31
0
        public void Setup()
        {
            nodeMap = new NodeMap();
            string[] names = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i" };
            foreach (string name in names)
            {
                nodeMap.Nodes.Add(new Node
                {
                    NodeName       = name,
                    ConnectedNodes = new LinkedList <KeyValuePair <Node, int> >()
                });
            }

            // A
            nodeMap.Nodes[0].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "b"), 3));
            nodeMap.Nodes[0].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "c"), 2));
            nodeMap.Nodes[0].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "d"), 5));

            // B
            nodeMap.Nodes[1].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "a"), 3));
            nodeMap.Nodes[1].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "e"), 8));

            // C
            nodeMap.Nodes[2].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "a"), 2));
            nodeMap.Nodes[2].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "e"), 6));

            // D
            nodeMap.Nodes[3].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "a"), 5));
            nodeMap.Nodes[3].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "h"), 4));

            // E
            nodeMap.Nodes[4].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "b"), 8));
            nodeMap.Nodes[4].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "c"), 6));
            nodeMap.Nodes[4].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "f"), 1));
            nodeMap.Nodes[4].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "g"), 2));
            nodeMap.Nodes[4].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "h"), 5));
            nodeMap.Nodes[4].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "i"), 7));

            // F
            nodeMap.Nodes[5].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "e"), 1));
            nodeMap.Nodes[5].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "g"), 9));

            // G
            nodeMap.Nodes[6].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "e"), 2));
            nodeMap.Nodes[6].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "h"), 8));

            // H
            nodeMap.Nodes[7].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "d"), 4));
            nodeMap.Nodes[7].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "e"), 5));
            nodeMap.Nodes[7].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "g"), 8));
            nodeMap.Nodes[7].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "i"), 1));

            // I
            nodeMap.Nodes[8].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "e"), 7));
            nodeMap.Nodes[8].ConnectedNodes.AddLast(new KeyValuePair <Node, int>(nodeMap.Nodes.Find(n => n.NodeName == "h"), 1));

            dijkstra = new Dijkstra(nodeMap);
        }
Пример #32
0
 public Value Read(Type field, NodeMap node, Dictionary map) {
    Node value = node.remove(ELEMENT_NAME);
    if(value == null) {
   	 return null;
    }
    String name = value.Value;
    Class type = Class.forName(name);
    return new SimpleType(type);
 }
Пример #33
0
		public ProxyPipe(NodeMap<LocalNode> locals, string uri)
		{
			Settings = new PipeSettings();
			var u = new Uri(uri);
			Settings.HostName = u.Host;
			Settings.Port = u.Port;
			Settings.BasePath = u.PathAndQuery;
			Nodes = new JArray(locals.Nodes.Select(node => new JObject(new JProperty("name", node.Name), new JProperty("classes", node.Classes)))).ToString();
			var listen = Task.Run(() => _listen());
		}
Пример #34
0
 public void TestIt()
 {
     List<object> results = new List<object>();
     NodeMap<LocalNode> locals = new NodeMap<LocalNode>();
     NodeMap<RemoteNode> remotes = new NodeMap<RemoteNode>();
     var NodeA = new LocalNode("NodeA", new string[] { "Calculator", "Printer" });
     locals.AddNode(NodeA);
     NodeA["Add"] = new FuncEx((sig, args, cb) =>
     {
         cb(new JArray(args[0].Value<int>() + args[1].Value<int>()));
     });
     NodeA["Print"] = new FuncEx((sig, args, cb) =>
     {
         results.Add(args[0].Value<int>());
     });
     Signal s = new Signal(locals, remotes);
     s.Load("NodeA.Calculator.Add(4,4)\n\t(res) => \n\t\tNodeA.Prinaster.Print(res)");
     s.Start();
     Assert.IsTrue(results.Count == 1 && (int)results[0] == 8);
 }
Пример #35
0
 /// <summary>
 /// This method is used to read an object from the specified node.
 /// In order to get the root type the field and node map are
 /// specified. The field represents the annotated method or field
 /// within the deserialized object. The node map is used to get
 /// the attributes used to describe the objects identity, or in
 /// the case of an existing object it contains an object reference.
 /// </summary>
 /// <param name="type">
 /// the method or field in the deserialized object
 /// </param>
 /// <param name="node">
 /// this is the XML element attributes to read
 /// </param>
 /// <param name="map">
 /// this is the session map used for deserialization
 /// </param>
 /// <returns>
 /// this returns an instance to insert into the object
 /// </returns>
 public Value Read(Type type, NodeMap node, Dictionary map) {
    ReadGraph graph = read.Find(map);
    if(graph != null) {
       return graph.Read(type, node);
    }
    return null;
 }
Пример #36
0
 /// <summary>
 /// This is used to recover the object references from the document
 /// using the special attributes specified. This allows the element
 /// specified by the <c>NodeMap</c> to be used to discover
 /// exactly which node in the object graph the element represents.
 /// </summary>
 /// <param name="type">
 /// the type of the field or method in the instance
 /// </param>
 /// <param name="real">
 /// this is the overridden type from the XML element
 /// </param>
 /// <param name="node">
 /// this is the XML element to be deserialized
 /// </param>
 /// <returns>
 /// this is used to return the type to acquire the value
 /// </returns>
 public Value ReadInstance(Type type, Class real, NodeMap node) {
    Node entry = node.remove(mark);
    if(entry == null) {
       return ReadReference(type, real, node);
    }
    String key = entry.getValue();
    if(containsKey(key)) {
       throw new CycleException("Element '%s' already exists", key);
    }
    return ReadValue(type, real, node, key);
 }
Пример #37
0
 public bool Write(Type field, Object value, NodeMap node, Dictionary map) {
    if(field.Type != value.getClass()) {
       node.put(ELEMENT_NAME, value.getClass().getName());
    }
    return false;
 }
Пример #38
0
 public void Read(Type type, NodeMap<InputNode> node) {
    InputNode element = node.getNode();
    if(element.isRoot()) {
       Object source = element.getSource();
       Class sourceType = source.getClass();
       Class itemType = type.getType();
       System.out.printf(">>>>> ELEMENT=[%s]%n>>>>> TYPE=[%s]%n>>>>> SOURCE=[%s]%n", element, itemType, sourceType);
    }
 }
Пример #39
0
 public void Write(Type type, NodeMap<OutputNode> node) {
    if(!node.getNode().isRoot()) {
       Comment comment = type.getAnnotation(Comment.class);
Пример #40
0
 /// <summary>
 /// This is used to acquire the <c>Value</c> which can be used
 /// to represent the deserialized value. The type create cab be
 /// added to the graph of created instances if the XML element has
 /// an identification attribute, this allows cycles to be completed.
 /// </summary>
 /// <param name="type">
 /// the type of the field or method in the instance
 /// </param>
 /// <param name="real">
 /// this is the overridden type from the XML element
 /// </param>
 /// <param name="node">
 /// this is the XML element to be deserialized
 /// </param>
 /// <returns>
 /// this is used to return the type to acquire the value
 /// </returns>
 public Value ReadValue(Type type, Class real, NodeMap node) {
    Class expect = type.getType();
    if(expect.isArray()) {
       return ReadArray(type, real, node);
    }
    return new ObjectValue(real);
 }
Пример #41
0
 /// <summary>
 /// This is used to acquire the <c>Value</c> which can be used
 /// to represent the deserialized value. The type create cab be
 /// added to the graph of created instances if the XML element has
 /// an identification attribute, this allows cycles to be completed.
 /// </summary>
 /// <param name="type">
 /// the type of the field or method in the instance
 /// </param>
 /// <param name="real">
 /// this is the overridden type from the XML element
 /// </param>
 /// <param name="node">
 /// this is the XML element to be deserialized
 /// </param>
 /// <param name="key">
 /// the key the instance is known as in the graph
 /// </param>
 /// <returns>
 /// this is used to return the type to acquire the value
 /// </returns>
 public Value ReadValue(Type type, Class real, NodeMap node, String key) {
    Value value = ReadValue(type, real, node);
    if(key != null) {
       return new Allocate(value, this, key);
    }
    return value;
 }
Пример #42
0
 public PipeModelInfo(Knot knot, NodeMap nodeMap, Edge edge, Vector3 offset)
     : base("pipe1")
 {
     Knot = knot;
     NodeMap = nodeMap;
     Edge = edge;
     Node node1 = nodeMap.FromNode (edge);
     Node node2 = nodeMap.ToNode (edge);
     PositionFrom = node1.ToVector () + offset;
     PositionTo = node2.ToVector () + offset;
     Position = node1.CenterBetween (node2) + offset;
     Direction = PositionTo - PositionFrom;
     Direction.Normalize ();
     Scale = Vector3.One * 10f;
     // a pipe is movable
     IsMovable = true;
 }
Пример #43
0
 /// <summary>
 /// This is used to write the reference in to the XML element that
 /// is to be written. This will either insert an object identity if
 /// the object has not previously been written, or, if the object
 /// has already been written in a previous element, this will write
 /// the reference to that object. This allows all cycles within the
 /// graph to be serialized so that they can be fully deserialized.
 /// </summary>
 /// <param name="type">
 /// the type of the field or method in the object
 /// </param>
 /// <param name="value">
 /// this is the actual object that is to be written
 /// </param>
 /// <param name="node">
 /// this is the XML element attribute map to use
 /// </param>
 /// <param name="map">
 /// this is the session map used for the serialization
 /// </param>
 /// <returns>
 /// returns true if the object has been fully serialized
 /// </returns>
 public bool Write(Type type, Object value, NodeMap node, Dictionary map) {
    WriteGraph graph = write.Find(map);
    if(graph != null) {
       return graph.Write(type, value, node);
    }
    return false;
 }
Пример #44
0
 public void Read(Type type, NodeMap<InputNode> node) {
Пример #45
0
 /// <summary>
 /// This is used to recover the object references from the document
 /// using the special attributes specified. This allows the element
 /// specified by the <c>NodeMap</c> to be used to discover
 /// exactly which node in the object graph the element represents.
 /// </summary>
 /// <param name="type">
 /// the type of the field or method in the instance
 /// </param>
 /// <param name="real">
 /// this is the overridden type from the XML element
 /// </param>
 /// <param name="node">
 /// this is the XML element to be deserialized
 /// </param>
 /// <returns>
 /// this is used to return the type to acquire the value
 /// </returns>
 public Value ReadReference(Type type, Class real, NodeMap node) {
    Node entry = node.remove(refer);
    if(entry == null) {
       return ReadValue(type, real, node);
    }
    String key = entry.getValue();
    Object value = get(key);
    if(!containsKey(key)) {
       throw new CycleException("Invalid reference '%s' found", key);
    }
    return new Reference(value, real);
 }
Пример #46
0
 public void Write(Type type, NodeMap<OutputNode> node) {
    if(!node.getNode().isRoot()) {
       node.getNode().setComment(type.getType().getName());
    }
 }
Пример #47
0
 /// <summary>
 /// This method will write with an internal strategy before it has
 /// been intercepted by the visitor. Interception of the XML node
 /// before it is delegated to the internal strategy allows the
 /// visitor to change some attributes or details before the node
 /// is interpreted by the strategy.
 /// </summary>
 /// <param name="type">
 /// this is the type of the root element expected
 /// </param>
 /// <param name="node">
 /// this is the node map used to resolve an override
 /// </param>
 /// <param name="map">
 /// this is used to maintain contextual information
 /// </param>
 /// <returns>
 /// the value that should be used to describe the instance
 /// </returns>
 public bool Write(Type type, Object value, NodeMap<OutputNode> node, Dictionary map) {
    bool result = strategy.Write(type, value, node, map);
    if(visitor != null) {
       visitor.Write(type, node);
    }
    return result;
 }
 public void Read(Type field, NodeMap<InputNode> node) {
    String namespace = node.getNode().getReference();
Пример #49
0
 /// <summary>
 /// This method will read with  an internal strategy after it has
 /// been intercepted by the visitor. Interception of the XML node
 /// before it is delegated to the internal strategy allows the
 /// visitor to change some attributes or details before the node
 /// is interpreted by the strategy.
 /// </summary>
 /// <param name="type">
 /// this is the type of the root element expected
 /// </param>
 /// <param name="node">
 /// this is the node map used to resolve an override
 /// </param>
 /// <param name="map">
 /// this is used to maintain contextual information
 /// </param>
 /// <returns>
 /// the value that should be used to describe the instance
 /// </returns>
 public Value Read(Type type, NodeMap<InputNode> node, Dictionary map) {
    if(visitor != null) {
       visitor.Read(type, node);
    }
    return strategy.Read(type, node, map);
 }
Пример #50
0
 /// <summary>
 /// This is used to read the <c>Value</c> which will be used
 /// to represent the deserialized object. If there is an annotation
 /// present then the value will contain an object instance. If it
 /// does not then it is up to the internal strategy to determine
 /// what the returned value contains.
 /// </summary>
 /// <param name="type">
 /// this is the type that represents a method or field
 /// </param>
 /// <param name="node">
 /// this is the node representing the XML element
 /// </param>
 /// <param name="value">
 /// this is the value from the internal strategy
 /// </param>
 /// <returns>
 /// the value representing the deserialized value
 /// </returns>
 public Value Read(Type type, NodeMap<InputNode> node, Value value) {
    Converter converter = scanner.GetConverter(type, value);
    InputNode parent = node.getNode();
    if(converter != null) {
       Object data = converter.Read(parent);
       if(value != null) {
          value.setValue(data);
       }
       return new Reference(value, data);
    }
    return value;
 }
Пример #51
0
 /// <summary>
 /// This is used to resolve and load a class for the given element.
 /// Resolution of the class to used is done by inspecting the
 /// XML element provided. If there is a "class" attribute on the
 /// element then its value is used to resolve the class to use.
 /// This also expects a "length" attribute for the array length.
 /// </summary>
 /// <param name="type">
 /// this is the type of the XML element expected
 /// </param>
 /// <param name="node">
 /// this is the element used to resolve an override
 /// </param>
 /// <returns>
 /// returns the class that should be used for the object
 /// </returns>
 public Value ReadArray(Class type, NodeMap node) {
    Node entry = node.remove(length);
    int size = 0;
    if(entry != null) {
       String value = entry.getValue();
       size = Integer.parseInt(value);
    }
    return new ArrayValue(type, size);
 }
Пример #52
0
 /// <summary>
 /// This is used to resolve and load a class for the given element.
 /// Resolution of the class to used is done by inspecting the
 /// XML element provided. If there is a "class" attribute on the
 /// element then its value is used to resolve the class to use.
 /// If no such attribute exists the specified field is returned,
 /// or if the field type is an array then the component type.
 /// </summary>
 /// <param name="type">
 /// this is the type of the XML element expected
 /// </param>
 /// <param name="node">
 /// this is the element used to resolve an override
 /// </param>
 /// <returns>
 /// returns the class that should be used for the object
 /// </returns>
 public Class ReadValue(Type type, NodeMap node) {
    Node entry = node.remove(label);
    Class expect = type.getType();
    if(expect.isArray()) {
       expect = expect.getComponentType();
    }
    if(entry != null) {
       String name = entry.getValue();
       expect = loader.Load(name);
    }
    return expect;
 }
Пример #53
0
 /// <summary>
 /// This is used to serialize a representation of the object value
 /// provided. If there is a <c>Convert</c> annotation present
 /// on the provided type then this will use the converter specified
 /// to serialize a representation of the object. If however there
 /// is no annotation then this will delegate to the internal
 /// strategy. This returns true if the serialization has completed.
 /// </summary>
 /// <param name="type">
 /// this is the type that represents the field or method
 /// </param>
 /// <param name="value">
 /// this is the object instance to be serialized
 /// </param>
 /// <param name="node">
 /// this is the XML element to be serialized to
 /// </param>
 /// <returns>
 /// this returns true if it was serialized, false otherwise
 /// </returns>
 public bool Write(Type type, Object value, NodeMap<OutputNode> node) {
    Converter converter = scanner.GetConverter(type, value);
    OutputNode parent = node.getNode();
    if(converter != null) {
       converter.Write(parent, value);
       return true;
    }
    return false;
 }
Пример #54
0
 /// <summary>
 /// This is used to attach a attribute to the provided element
 /// that is used to identify the class. The attribute name is
 /// "class" and has the value of the fully qualified class
 /// name for the object provided. This will only be invoked
 /// if the object class is different from the field class.
 /// </summary>
 /// <param name="type">
 /// this is the declared class for the field used
 /// </param>
 /// <param name="value">
 /// this is the instance variable being serialized
 /// </param>
 /// <param name="node">
 /// this is the element used to represent the value
 /// </param>
 /// <param name="map">
 /// this is used to maintain contextual information
 /// </param>
 /// <returns>
 /// this returns true if serialization is complete
 /// </returns>
 public bool Write(Type type, Object value, NodeMap node, Dictionary map) {
    Class actual = value.getClass();
    Class expect = type.getType();
    Class real = actual;
    if(actual.isArray()) {
       real = WriteArray(expect, value, node);
    }
    if(actual != expect) {
       node.put(label, real.getName());
    }
    return false;
 }
Пример #55
0
 /// <summary>
 /// This is used to add a length attribute to the element due to
 /// the fact that the serialized value is an array. The length
 /// of the array is acquired and inserted in to the attributes.
 /// </summary>
 /// <param name="field">
 /// this is the field type for the array to set
 /// </param>
 /// <param name="value">
 /// this is the actual value for the array to set
 /// </param>
 /// <param name="node">
 /// this is the map of attributes for the element
 /// </param>
 /// <returns>
 /// returns the array component type that is set
 /// </returns>
 public Class WriteArray(Class field, Object value, NodeMap node) {
    int size = Array.getLength(value);
    if(length != null) {
       node.put(length, String.valueOf(size));
    }
    return field.getComponentType();
 }
Пример #56
0
 /// <summary>
 /// This is used to serialize a representation of the object value
 /// provided. If there is a <c>Convert</c> annotation present
 /// on the provided type then this will use the converter specified
 /// to serialize a representation of the object. If however there
 /// is no annotation then this will delegate to the internal
 /// strategy. This returns true if the serialization has completed.
 /// </summary>
 /// <param name="type">
 /// this is the type that represents the field or method
 /// </param>
 /// <param name="value">
 /// this is the object instance to be serialized
 /// </param>
 /// <param name="node">
 /// this is the XML element to be serialized to
 /// </param>
 /// <param name="map">
 /// this is the session map used by the serializer
 /// </param>
 /// <returns>
 /// this returns true if it was serialized, false otherwise
 /// </returns>
 public bool Write(Type type, Object value, NodeMap<OutputNode> node, Dictionary map) {
    bool reference = strategy.Write(type, value, node, map);
    if(!reference) {
       return Write(type, value, node);
    }
    return reference;
 }
Пример #57
0
 /// <summary>
 /// This is used to resolve and load a class for the given element.
 /// Resolution of the class to used is done by inspecting the
 /// XML element provided. If there is a "class" attribute on the
 /// element then its value is used to resolve the class to use.
 /// If no such attribute exists on the element this returns null.
 /// </summary>
 /// <param name="type">
 /// this is the type of the XML element expected
 /// </param>
 /// <param name="node">
 /// this is the element used to resolve an override
 /// </param>
 /// <param name="map">
 /// this is used to maintain contextual information
 /// </param>
 /// <returns>
 /// returns the class that should be used for the object
 /// </returns>
 public Value Read(Type type, NodeMap node, Dictionary map) {
    Class actual = ReadValue(type, node);
    Class expect = type.getType();
    if(expect.isArray()) {
       return ReadArray(actual, node);
    }
    if(expect != actual) {
       return new ObjectValue(actual);
    }
    return null;
 }
Пример #58
0
 /// <summary>
 /// This is used to read the <c>Value</c> which will be used
 /// to represent the deserialized object. If there is an annotation
 /// present then the value will contain an object instance. If it
 /// does not then it is up to the internal strategy to determine
 /// what the returned value contains.
 /// </summary>
 /// <param name="type">
 /// this is the type that represents a method or field
 /// </param>
 /// <param name="node">
 /// this is the node representing the XML element
 /// </param>
 /// <param name="map">
 /// this is the session map that contain variables
 /// </param>
 /// <returns>
 /// the value representing the deserialized value
 /// </returns>
 public Value Read(Type type, NodeMap<InputNode> node, Dictionary map) {
    Value value = strategy.Read(type, node, map);
    if(IsReference(value)) {
       return value;
    }
    return Read(type, node, value);
 }
Пример #59
0
		public Funcis(string sigPath = @"\Signals")
		{
			locals = new NodeMap<LocalNode>();
			remotes = new NodeMap<RemoteNode>();
			this.sigPath = sigPath;
		}