Exemplo n.º 1
0
    //might be inefficent. should maybe check if file already exists and then write to it
    public void Save()
    {
        //BinaryFormatter bf = new BinaryFormatter();
        XmlSerializer ser  = new XmlSerializer(typeof(DataSerializer));
        FileStream    file = File.Create(Application.persistentDataPath + "/appInfo22.dat");

        /*foreach (KeyValuePair<string, DataPiece> pair in central_dictionary)
         * {
         *  DataPiece dt = pair.Value;
         *  DetectorSerializer t2 = new DetectorSerializer();
         *  t2.beforeSter(dt.detectors);
         *  dt.detector_saver = t2;
         * }*/
        //Debug.LogError("In Save()");

        DataSerializer t = new DataSerializer();

        t.beforeSter(DataPieceSer.changeDataPieceDictionary(SavedData.data.central_dictionary));
        //bf.Serialize(file, t);
        ser.Serialize(file, t);
        //file.Close();
        file.Dispose();

        /*Debug.LogError("The to be saved Keys:" + SavedData.data.central_dictionary.Keys.Count);
         *
         * string debug_string = "Saved Data: ";
         * foreach (KeyValuePair<string, DataPiece> pair in SavedData.data.central_dictionary)
         * {
         *  debug_string += pair.Key + " = " + pair.Value.toString();
         * }
         * Debug.LogError(debug_string);*/
    }
Exemplo n.º 2
0
    public static DataPieceSer changeDataPiecetoDataPieceSer(DataPiece d)
    {
        DataPieceSer ans = new DataPieceSer();

        ans.datatype  = d.datatype;
        ans.id        = d.id;
        ans.firstName = d.firstName;
        ans.lastName  = d.lastName;

        if (d.classes == null)
        {
            ans.classes = null;
        }
        else
        {
            ans.classes = d.classes.ToArray();
        }

        ans.class_summary = d.class_summary;
        if (d.students == null)
        {
            ans.students = null;
        }
        else
        {
            ans.students = d.students.ToArray();
        }

        ans.infoBeingDisplayed = d.infoBeingDisplayed;
        ans.detector_saver     = new DetectorSerializer();
        ans.detector_saver.beforeSter(d.detectors);
        return(ans);
    }
Exemplo n.º 3
0
    public DetectorSerializer detector_saver; //Use this to serialze the dectors [different procedure bc it's a dictionary]

    public static DataPiece changeDataPieceSertoDataPiece(DataPieceSer d)
    {
        DataPiece ans = new DataPiece();

        ans.datatype  = d.datatype;
        ans.id        = d.id;
        ans.firstName = d.firstName;
        ans.lastName  = d.lastName;

        if (d.classes == null)
        {
            ans.classes = new List <string>();
        }
        else
        {
            ans.classes = new List <string>(d.classes);
        }

        ans.class_summary = d.class_summary;

        if (d.students == null)
        {
            ans.students = new List <string>();
        }
        else
        {
            ans.students = new List <string>(d.students);
        }

        ans.infoBeingDisplayed = d.infoBeingDisplayed;
        ans.detectors          = d.detector_saver.afterSter();
        return(ans);
    }
Exemplo n.º 4
0
    public Dictionary <string, DataPiece> afterSter()
    {
        Dictionary <string, DataPiece> dic = new Dictionary <string, DataPiece>();

        for (int i = 0; i < keys.Length; i++)
        {
            dic.Add(keys[i], DataPieceSer.changeDataPieceSertoDataPiece(values[i]));
        }
        return(dic);
    }