Пример #1
0
    public override void Deserialize(SavedState _savedState)
    {
        base.Deserialize(_savedState);

        /*IFormatter formatter = new BinaryFormatter();
         *
         * Stream stream = new FileStream("C:\\Users\\Natspir\\NatspirProd\\Test.assetProd", FileMode.Open, FileAccess.Read);
         * string[] imgPaths = ((ConceptState)formatter.Deserialize(stream)).ImgPaths;
         * stream.Close();*/
        ConceptState conceptState = ((ConceptState)_savedState);

        //Debug.Log(imgPaths);
        m_view.LoadConcepts(conceptState.ImgPaths);
        //load the state of the task
        HandleUpdateConcept(this, new UpdateStateEvent(conceptState.StateTask));
    }
Пример #2
0
    public override SavedState Serialize()
    {
        string[] imgPaths = new string[m_concepts.Count];
        int      index    = 0;

        foreach (string imgPath in m_concepts.Values)
        {
            imgPaths[index] = imgPath;
            index++;
        }
        Debug.Log("Saving concept");
        MementoHandler m  = new MementoHandler(); //using memento pattern to handle saving/loading and also undo/redo in the
        ConceptState   cs = new ConceptState(imgPaths, m_state);

        m.SetState(cs); //will move when a new concept is added, to handle undo/redo functionality
        return(m.GetState());

/*        IFormatter formatter = new BinaryFormatter();
 *      Stream stream = new FileStream("C:\\Users\\Natspir\\NatspirProd\\Test.assetProd", FileMode.Create, FileAccess.Write);
 *      formatter.Serialize(stream, m.GetState());
 *      stream.Close();*/
    }