Ejemplo n.º 1
0
    /// <summary>
    /// Method that write in JSON file.
    /// </summary>
    public void Write(Info data)
    {
        InfoSerializer serializer = new InfoSerializer();

        using (StreamWriter sw = new StreamWriter(_fullFileName))
        {
            serializer.SerializeToFile(sw, data);
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Method that Read from JSON file.
    /// </summary>
    public Info Read()
    {
        if (!File.Exists(_fullFileName))         // Checkin if we have json file.
        {
            NewPlayer();
        }
        InfoSerializer serializer = new InfoSerializer();
        Info           data       = null;

        using (StreamReader sr = new StreamReader(_fullFileName))
        {
            data = serializer.DerializeFromFile(sr);
        }
        return(data);
    }