Пример #1
0
        public void DeserializeObjects()
        {
            Object objectToDeserialize = null;

            try
            {
                while (stream.CanSeek)
                {
                    objectToDeserialize = (Object)bformatter.Deserialize(stream);
                    if (objectToDeserialize is SerialNode)
                    {
                        SerialNode serialNode = (SerialNode)objectToDeserialize;
                        Node       node       = new Node(serialNode);
                    }
                    else if (objectToDeserialize is SerialRelation)
                    {
                        SerialRelation serialRelation = (SerialRelation)objectToDeserialize;
                        Relation       rel            = new Relation(serialRelation);
                    }
                }
            }
            catch (SerializationException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("EndoOfFile");
            }
        }
Пример #2
0
        public void Serialize(string filename)
        {
            SerializeData data = new SerializeData(filename + ".gombi");

            Node[] nodes = MDiagram.Nodes;
            foreach (Node node in nodes)
            {
                SerialNode serial = node.Serialize();
                data.SerializeObject(serial);
            }
            Relation[] relations = MDiagram.Relations;
            foreach (Relation rel in relations)
            {
                SerialRelation serial = rel.Serialize();
                data.SerializeObject(serial);
            }
            data.CloseStream();
        }