示例#1
0
 private void UpdateNodesAndSlostWithResolveMissingSlotAfterAction(IStorage storage, List<IVisualNode> nodeList, List<uint> slotIdList)
 {
     DataHeader header = new DataHeader();
     storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of slots stored
     foreach (uint slotId in slotIdList)
     {
         header.Deserialize(storage);
         if (this.graphController.ContainSlotKey(slotId))
         {
             ISlot slot = this.graphController.GetSlot(slotId);
             slot.Deserialize(storage);
         }
         else
         {
             ISlot slot = Slot.Create(this.graphController, storage);
             this.graphController.AddSlot(slot);
         }
     }
     storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of nodes stored
     foreach (IVisualNode node in nodeList)
     {
         header.Deserialize(storage);
         node.Deserialize(storage);
     }
 }
        private void UpdateRuntimeStates(IStorage storage, RuntimeStates runtimeStates)
        {
            DataHeader header = new DataHeader();

            header.Deserialize(storage);
            runtimeStates.Deserialize(storage);
        }
示例#3
0
 private void UpdateEdges(IStorage storage, List<IVisualEdge> edgeList)
 {
     DataHeader header = new DataHeader();
     storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of edges stored
     foreach (IVisualEdge edge in edgeList)
     {
         header.Deserialize(storage);
         edge.Deserialize(storage);
     }
 }
示例#4
0
        public void TestSerializeNullException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage storage = null;
            DataHeader header = new DataHeader();

            Assert.Throws<ArgumentNullException>(() =>
            {
                header.Serialize(storage);
            });
        }
        private void RecordNodesAndSlots(IStorage storage, List <IVisualNode> nodeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            long       initialPostionForData, currentPositionForData = 0;
            long       initialPosition = storage.GetPosition();

            //Retrieve all the slots Id in nodeList
            List <uint> allSlotsId = new List <uint>();

            foreach (IVisualNode node in nodeList)
            {
                if (node.GetInputSlots() != null)
                {
                    allSlotsId.AddRange(node.GetInputSlots());
                }
                if (node.GetOutputSlots() != null)
                {
                    allSlotsId.AddRange(node.GetOutputSlots());
                }
            }

            //Record the number of slots and the slot itself
            storage.WriteInteger(FieldCode.SlotCount, allSlotsId.Count());
            foreach (uint slotId in allSlotsId)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPostionForData = storage.GetPosition();
                ISlot slot = this.graphController.GetSlot(slotId);
                slot.Serialize(storage);
                currentPositionForData = storage.GetPosition();
                header.DataSize        = currentPositionForData - initialPostionForData;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            //Record the number of nodes and the node itself
            storage.WriteInteger(FieldCode.NodeCount, nodeList.Count);
            foreach (IVisualNode node in nodeList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPostionForData = storage.GetPosition();
                node.Serialize(storage);
                currentPositionForData = storage.GetPosition();
                header.DataSize        = currentPositionForData - initialPostionForData;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
示例#6
0
 private List<IVisualNode> RetrieveNodesFromStorage(IStorage storage)
 {
     DataHeader header = new DataHeader();
     List<IVisualNode> nodeList = new List<IVisualNode>();
     int nodeCount = storage.ReadInteger(FieldCode.NodeCount);
     for (int i = 0; i < nodeCount; i++)
     {
         header.Deserialize(storage);
         IVisualNode node = VisualNode.Create(this.graphController, storage);
         nodeList.Add(node);
     }
     return nodeList;
 }
示例#7
0
 private List<IVisualNode> RetrieveNodesFromIdsInStorage(IStorage storage)
 {
     DataHeader header = new DataHeader();
     List<IVisualNode> nodeList = new List<IVisualNode>();
     int nodeCount = storage.ReadInteger(FieldCode.NodeCount);
     for (int i = 0; i < nodeCount; i++)
     {
         header.Deserialize(storage);
         uint nodeId = storage.ReadUnsignedInteger(FieldCode.NodeId);
         nodeList.Add(this.graphController.GetVisualNode(nodeId));
     }
     return nodeList;
 }
示例#8
0
 private List<ISlot> RetrieveSlotsFromStorage(IStorage storage)
 {
     DataHeader header = new DataHeader();
     List<ISlot> slotList = new List<ISlot>();
     int slotCount = storage.ReadInteger(FieldCode.SlotCount);
     for (int i = 0; i < slotCount; i++)
     {
         header.Deserialize(storage);
         ISlot slot = Slot.Create(this.graphController, storage);
         slotList.Add(slot);
     }
     return slotList;
 }
示例#9
0
 private List<IVisualEdge> RetrieveEdgesFromStorage(IStorage storage)
 {
     DataHeader header = new DataHeader();
     List<IVisualEdge> edgeList = new List<IVisualEdge>();
     int edgeCount = storage.ReadInteger(FieldCode.EdgeCount);
     for (int i = 0; i < edgeCount; i++)
     {
         header.Deserialize(storage);
         IVisualEdge edge = this.graphController.CreateEdgeFromStorage(storage);
         edgeList.Add(edge);
     }
     return edgeList;
 }
示例#10
0
        public void TestDeserilaizeOperationException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage storage = new BinaryStorage();
            DataHeader header = new DataHeader();

            storage.WriteUnsignedInteger(FieldCode.DataHeaderSignature, 21);
            storage.Seek(0, SeekOrigin.Begin);

            Assert.Throws<InvalidOperationException>(() =>
            {
                header.Deserialize(storage);
            });
        }
        private List <IVisualEdge> RetrieveEdgesFromIdsInStorage(IStorage storage)
        {
            DataHeader         header   = new DataHeader();
            List <IVisualEdge> edgeList = new List <IVisualEdge>();
            int edgeCount = storage.ReadInteger(FieldCode.EdgeCount);

            for (int i = 0; i < edgeCount; i++)
            {
                header.Deserialize(storage);
                uint edgeId = storage.ReadUnsignedInteger(FieldCode.EdgeId);
                edgeList.Add(this.graphController.GetVisualEdge(edgeId));
            }
            return(edgeList);
        }
示例#12
0
 private List<uint> RetrieveNodeIdsFromStorage(IStorage storage)
 {
     DataHeader header = new DataHeader();
     List<uint> nodeIdList = new List<uint>();
     int nodeCount = storage.ReadInteger(FieldCode.NodeCount);
     for (int i = 0; i < nodeCount; i++)
     {
         header.Deserialize(storage);
         storage.Seek(36, SeekOrigin.Current);
         nodeIdList.Add(storage.ReadUnsignedInteger(FieldCode.NodeId));
         storage.Seek(header.DataSize - 48, SeekOrigin.Current);
     }
     return nodeIdList;
 }
示例#13
0
        public void TestSerializeDeserialize()
        {
            IGraphController graphController = new GraphController(null);
            IStorage storage = new BinaryStorage();
            DataHeader header1 = new DataHeader();
            header1.DataSize = 21;
            DataHeader header2 = new DataHeader();
            header2.DataSize = 12;

            header1.Serialize(storage);
            storage.Seek(0, SeekOrigin.Begin);
            header2.Deserialize(storage);

            Assert.AreEqual(21, header2.DataSize);
        }
示例#14
0
        private void RecordEdgeIds(IStorage storage, List<IVisualEdge> edgeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            header.DataSize = 12;
            long initialPosition = storage.GetPosition();

            //Record the number of edges and the edgeIds
            storage.WriteInteger(FieldCode.EdgeCount, edgeList.Count);
            foreach (IVisualEdge edge in edgeList)
            {
                header.Serialize(storage);
                storage.WriteUnsignedInteger(FieldCode.EdgeId, edge.EdgeId);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
示例#15
0
        private void RecordNodeIds(IStorage storage, List<IVisualNode> nodeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            header.DataSize = Configurations.UndoReDoDataHeaderSize;
            long initialPosition = storage.GetPosition();

            //Record the number of nodes and the nodeIds
            storage.WriteInteger(FieldCode.NodeCount, nodeList.Count);
            foreach (IVisualNode node in nodeList)
            {
                header.Serialize(storage);
                storage.WriteUnsignedInteger(FieldCode.NodeId, node.NodeId);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
示例#16
0
        private void RecordRuntimeStates(IStorage storage, RuntimeStates runtimeStates, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            long initialPosition = storage.GetPosition();

            //Record states
            storage.Seek(header.HeaderSize, SeekOrigin.Current);
            long initialPositionForData = storage.GetPosition();
            runtimeStates.Serialize(storage);
            long currentPositionforData = storage.GetPosition();
            header.DataSize = currentPositionforData - initialPositionForData;
            storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
            header.Serialize(storage);
            storage.Seek(header.DataSize, SeekOrigin.Current);

            this.RecordFlag(storage, initialPosition, userAction);
        }
示例#17
0
        private void RecordEdges(IStorage storage, List<IVisualEdge> edgeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            long initialPostionForData, currentPositionForData = 0;
            long initialPosition = storage.GetPosition();

            //Record the number of edges and the edge itself
            storage.WriteInteger(FieldCode.EdgeCount, edgeList.Count);
            foreach (IVisualEdge edge in edgeList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPostionForData = storage.GetPosition();
                edge.Serialize(storage);
                currentPositionForData = storage.GetPosition();
                header.DataSize = currentPositionForData - initialPostionForData;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
示例#18
0
 private List<IVisualNode> RetrieveNodesFromIdsInStorage(IStorage storage)
 {
     DataHeader header = new DataHeader();
     List<IVisualNode> nodeList = new List<IVisualNode>();
     int nodeCount = storage.ReadInteger(FieldCode.NodeCount);
     for (int i = 0; i < nodeCount; i++)
     {
         header.Deserialize(storage);
         uint nodeId = storage.ReadUnsignedInteger(FieldCode.NodeId);
         nodeList.Add(this.graphController.GetVisualNode(nodeId));
     }
     return nodeList;
 }
示例#19
0
 private List<IVisualEdge> RetrieveEdgesFromStorage(IStorage storage)
 {
     DataHeader header = new DataHeader();
     List<IVisualEdge> edgeList = new List<IVisualEdge>();
     int edgeCount = storage.ReadInteger(FieldCode.EdgeCount);
     for (int i = 0; i < edgeCount; i++)
     {
         header.Deserialize(storage);
         IVisualEdge edge = this.graphController.CreateEdgeFromStorage(storage);
         edgeList.Add(edge);
     }
     return edgeList;
 }
示例#20
0
        private void RecordRuntimeStates(IStorage storage, RuntimeStates runtimeStates, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            long initialPosition = storage.GetPosition();

            //Record states
            storage.Seek(header.HeaderSize, SeekOrigin.Current);
            long initialPositionForData = storage.GetPosition();
            runtimeStates.Serialize(storage);
            long currentPositionforData = storage.GetPosition();
            header.DataSize = currentPositionforData - initialPositionForData;
            storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
            header.Serialize(storage);
            storage.Seek(header.DataSize, SeekOrigin.Current);

            this.RecordFlag(storage, initialPosition, userAction);
        }
示例#21
0
        private void RecordNodesAndSlots(IStorage storage, List<IVisualNode> nodeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            long initialPostionForData, currentPositionForData = 0;
            long initialPosition = storage.GetPosition();

            //Retrieve all the slots Id in nodeList
            List<uint> allSlotsId = new List<uint>();
            foreach (IVisualNode node in nodeList)
            {
                if (node.GetInputSlots() != null)
                    allSlotsId.AddRange(node.GetInputSlots());
                if (node.GetOutputSlots() != null)
                    allSlotsId.AddRange(node.GetOutputSlots());
            }

            //Record the number of slots and the slot itself
            storage.WriteInteger(FieldCode.SlotCount, allSlotsId.Count());
            foreach (uint slotId in allSlotsId)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPostionForData = storage.GetPosition();
                ISlot slot = this.graphController.GetSlot(slotId);
                slot.Serialize(storage);
                currentPositionForData = storage.GetPosition();
                header.DataSize = currentPositionForData - initialPostionForData;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            //Record the number of nodes and the node itself
            storage.WriteInteger(FieldCode.NodeCount, nodeList.Count);
            foreach (IVisualNode node in nodeList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPostionForData = storage.GetPosition();
                node.Serialize(storage);
                currentPositionForData = storage.GetPosition();
                header.DataSize = currentPositionForData - initialPostionForData;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
示例#22
0
        private void RecordNodeIds(IStorage storage, List<IVisualNode> nodeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            header.DataSize = Configurations.UndoReDoDataHeaderSize;
            long initialPosition = storage.GetPosition();

            //Record the number of nodes and the nodeIds
            storage.WriteInteger(FieldCode.NodeCount, nodeList.Count);
            foreach (IVisualNode node in nodeList)
            {
                header.Serialize(storage);
                storage.WriteUnsignedInteger(FieldCode.NodeId, node.NodeId);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
示例#23
0
 private List<ISlot> RetrieveSlotsFromStorage(IStorage storage)
 {
     DataHeader header = new DataHeader();
     List<ISlot> slotList = new List<ISlot>();
     int slotCount = storage.ReadInteger(FieldCode.SlotCount);
     for (int i = 0; i < slotCount; i++)
     {
         header.Deserialize(storage);
         ISlot slot = Slot.Create(this.graphController, storage);
         slotList.Add(slot);
     }
     return slotList;
 }
        private void SaveFileInternal(string filePath)
        {
            IStorage storage = new FileStorage();
            DataHeader header = new DataHeader();
            long initialPosition, currentPosition = 0;

            //Serialize states
            storage.Seek(header.HeaderSize, SeekOrigin.Current);
            initialPosition = storage.GetPosition();
            this.graphProperties.Serialize(storage);
            currentPosition = storage.GetPosition();
            header.DataSize = currentPosition - initialPosition;
            storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
            header.Serialize(storage);
            storage.Seek(header.DataSize, SeekOrigin.Current);

            //Serialize slots
            List<ISlot> slotList = new List<ISlot>(this.slotCollection.Values);
            storage.WriteInteger(FieldCode.SlotCount, slotList.Count);
            foreach (ISlot slot in slotList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPosition = storage.GetPosition();
                slot.Serialize(storage);
                currentPosition = storage.GetPosition();
                header.DataSize = currentPosition - initialPosition;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            //Serialize nodes
            List<IVisualNode> nodeList = new List<IVisualNode>(this.nodeCollection.Values);
            storage.WriteInteger(FieldCode.NodeCount, nodeList.Count);
            foreach (IVisualNode node in nodeList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPosition = storage.GetPosition();
                node.Serialize(storage);
                currentPosition = storage.GetPosition();
                header.DataSize = currentPosition - initialPosition;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            //Serialize edges
            List<IVisualEdge> edgeList = this.edgeController.GetVisualEdges();
            storage.WriteInteger(FieldCode.EdgeCount, edgeList.Count);
            foreach (IVisualEdge edge in edgeList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPosition = storage.GetPosition();
                edge.Serialize(storage);
                currentPosition = storage.GetPosition();
                header.DataSize = currentPosition - initialPosition;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            ((FileStorage)storage).Save(filePath);
        }
示例#25
0
 private void UpdateNodesAndSlostWithResolveMissingSlotAfterAction(IStorage storage, List<IVisualNode> nodeList, List<uint> slotIdList)
 {
     DataHeader header = new DataHeader();
     storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of slots stored
     foreach (uint slotId in slotIdList)
     {
         header.Deserialize(storage);
         if (this.graphController.ContainSlotKey(slotId))
         {
             ISlot slot = this.graphController.GetSlot(slotId);
             slot.Deserialize(storage);
         }
         else
         {
             ISlot slot = Slot.Create(this.graphController, storage);
             this.graphController.AddSlot(slot);
         }
     }
     storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of nodes stored
     foreach (IVisualNode node in nodeList)
     {
         header.Deserialize(storage);
         node.Deserialize(storage);
     }
 }
示例#26
0
 private List<IVisualNode> RetrieveNodesFromStorage(IStorage storage)
 {
     DataHeader header = new DataHeader();
     List<IVisualNode> nodeList = new List<IVisualNode>();
     int nodeCount = storage.ReadInteger(FieldCode.NodeCount);
     for (int i = 0; i < nodeCount; i++)
     {
         header.Deserialize(storage);
         IVisualNode node = VisualNode.Create(this.graphController, storage);
         nodeList.Add(node);
     }
     return nodeList;
 }
示例#27
0
 private List<uint> RetrieveSlotIdsFromStorage(IStorage storage)
 {
     DataHeader header = new DataHeader();
     List<uint> slotIdList = new List<uint>();
     int slotCount = storage.ReadInteger(FieldCode.SlotCount);
     for (int i = 0; i < slotCount; i++)
     {
         header.Deserialize(storage);
         storage.Seek(36, SeekOrigin.Current);
         slotIdList.Add(storage.ReadUnsignedInteger(FieldCode.SlotId));
         storage.Seek(header.DataSize - 48, SeekOrigin.Current);
     }
     return slotIdList;
 }
示例#28
0
        private void RecordEdgeIds(IStorage storage, List<IVisualEdge> edgeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            header.DataSize = 12;
            long initialPosition = storage.GetPosition();

            //Record the number of edges and the edgeIds
            storage.WriteInteger(FieldCode.EdgeCount, edgeList.Count);
            foreach (IVisualEdge edge in edgeList)
            {
                header.Serialize(storage);
                storage.WriteUnsignedInteger(FieldCode.EdgeId, edge.EdgeId);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
示例#29
0
 private void UpdateEdges(IStorage storage, List<IVisualEdge> edgeList)
 {
     DataHeader header = new DataHeader();
     storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of edges stored
     foreach (IVisualEdge edge in edgeList)
     {
         header.Deserialize(storage);
         edge.Deserialize(storage);
     }
 }
示例#30
0
        private void RecordEdges(IStorage storage, List<IVisualEdge> edgeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            long initialPostionForData, currentPositionForData = 0;
            long initialPosition = storage.GetPosition();

            //Record the number of edges and the edge itself
            storage.WriteInteger(FieldCode.EdgeCount, edgeList.Count);
            foreach (IVisualEdge edge in edgeList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPostionForData = storage.GetPosition();
                edge.Serialize(storage);
                currentPositionForData = storage.GetPosition();
                header.DataSize = currentPositionForData - initialPostionForData;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
示例#31
0
 private void UpdateRuntimeStates(IStorage storage, RuntimeStates runtimeStates)
 {
     DataHeader header = new DataHeader();
     header.Deserialize(storage);
     runtimeStates.Deserialize(storage);
 }
        private void LoadFileInternal(string filePath)
        {
            FileStorage storage = new FileStorage();
            DataHeader header = new DataHeader();
            storage.Load(filePath);

            //Deserialize states
            header.Deserialize(storage);
            this.graphProperties.Deserialize(storage);

            foreach (string scriptPath in this.graphProperties.ImportedScripts)
            {
                CoreComponent.Instance.ImportAssembly(scriptPath, filePath, true);
            }

            //Deserialize slots
            int slotCount = storage.ReadInteger(FieldCode.SlotCount);
            for (int i = 0; i < slotCount; i++)
            {
                header.Deserialize(storage);
                ISlot slot = Slot.Create(this, storage);
                this.AddSlot(slot);
            }

            //Deserialize nodes
            int nodeCount = storage.ReadInteger(FieldCode.NodeCount);
            for (int j = 0; j < nodeCount; j++)
            {
                header.Deserialize(storage);
                IVisualNode node = VisualNode.Create(this, storage);
                this.AddVisualNode(node);
            }

            //Deserialize edges
            int edgeCount = storage.ReadInteger(FieldCode.EdgeCount);
            for (int j = 0; j < edgeCount; j++)
            {
                header.Deserialize(storage);
                IVisualEdge edge = VisualEdge.Create(this.edgeController, storage);
                this.AddVisualEdge(edge);
            }

            //AuditLoadedGraph();

            // These calls internally figure out the type of id
            // it is meant for, and set the value accordingly.
            if (nodeCount > 0)
                this.idGenerator.SetStartId(this.nodeCollection.Keys.Max());
            if (slotCount > 0)
                this.idGenerator.SetStartId(this.slotCollection.Keys.Max());
            if (edgeCount > 0)
                this.idGenerator.SetStartId(this.edgeController.GetMaxEdgeId());
        }