Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
        private void UpdateRuntimeStates(IStorage storage, RuntimeStates runtimeStates)
        {
            DataHeader header = new DataHeader();

            header.Deserialize(storage);
            runtimeStates.Deserialize(storage);
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 4
0
        public void TestDeserializeNullException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage storage = null;
            DataHeader header = new DataHeader();

            Assert.Throws<ArgumentNullException>(() =>
            {
                header.Deserialize(storage);
            });
        }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
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;
 }
Ejemplo n.º 7
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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 9
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);
            });
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
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;
 }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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);
     }
 }
Ejemplo n.º 14
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;
 }
Ejemplo n.º 15
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;
 }
Ejemplo n.º 16
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;
 }
Ejemplo n.º 17
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;
 }
Ejemplo n.º 18
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;
 }
Ejemplo n.º 19
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);
     }
 }
Ejemplo n.º 20
0
 private void UpdateRuntimeStates(IStorage storage, RuntimeStates runtimeStates)
 {
     DataHeader header = new DataHeader();
     header.Deserialize(storage);
     runtimeStates.Deserialize(storage);
 }
Ejemplo n.º 21
0
        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());
        }