public void Deserialize(Graph graph)
        {
            if (serializedData != null)
            {
                object obj = Serializer.Deserialize(serializedData, onBeforeDeserialize: BeforeDeserialize);

                SerializedDataProt prot = (SerializedDataProt)Serializer.Deserialize(serializedData, onBeforeDeserialize: BeforeDeserialize);
                CheckNullGenerators(prot.generators);
                CheckNullLinks(ref prot.linkInlets, ref prot.linkOutlets);

                graph.generators = prot.generators;
                graph.links      = new Dictionary <IInlet <object>, IOutlet <object> >();
                graph.links.AddRange(prot.linkInlets, prot.linkOutlets);
                graph.groups = prot.groups;

                graph.exposed = prot.exposed;
                if (graph.exposed == null)
                {
                    graph.exposed = new Exposed();
                }

                graph.defaults = prot.defaults;
                if (graph.defaults == null)
                {
                    graph.defaults = new Override();
                }

                graph.random = new Noise(prot.seed, 32768);

                //if (graph.serializedVersion < 210)
                graph.CheckFixIds();

                CheckInletsGensAssigned(graph);
            }
        }
示例#2
0
        public void Serialize(Graph graph)
        {
            SerializedDataProt prot = new SerializedDataProt()
            {
                ver         = MapMagicObject.version,
                generators  = graph.generators,
                linkInlets  = graph.links.Keys.ToArray(),
                linkOutlets = graph.links.Values.ToArray(),
                groups      = graph.groups,
                exposed     = graph.exposed
            };

            serializedData = Serializer.Serialize(prot, onAfterSerialize: AfterSerialize);
        }
示例#3
0
        public void Deserialize(Graph graph)
        {
            if (serializedData != null)
            {
                object obj = Serializer.Deserialize(serializedData, onBeforeDeserialize: BeforeDeserialize);

                SerializedDataProt prot = (SerializedDataProt)Serializer.Deserialize(serializedData, onBeforeDeserialize: BeforeDeserialize);
                graph.generators = prot.generators;
                graph.links      = new Dictionary <IInlet <object>, IOutlet <object> >();
                graph.links.AddRange(prot.linkInlets, prot.linkOutlets);
                graph.groups  = prot.groups;
                graph.exposed = prot.exposed;

                CheckInletsGensAssigned(graph);
            }
        }