Skip to content

mogoson/MGS.FileAvatar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MGS.FileAvatar

Summary

  • Avatar for text file to read and write data.

Environment

  • Unity 5.3 or above.
  • .Net Framework 3.5 or above.

Platform

  • Windows.

Demand

  • Read Json file to structure data, modify and write data to text file.
  • Read key value lines file to dictionary data, modify and write data to text file.

Design

  • FileAvatar class to read and write text file content.
  • JsonFileAvatar class inherit from FileAvatar to serialize content to structure data.
  • KeyFileAvatar class inherit from FileAvatar to convert content to dictionary data.

Usage

//Key Value Line file.
var avatar = new KeyFileAvatar(file);//Auto pull content form file.
var value = avatar.GetValue(key);
avatar.SetValue(key, value);//Commit to cache.
avatar.Push();//Write content to local file.

//Json file.
var avatar = new JsonFileAvatar<Info>(file);//Auto pull content form file.
var info = avatar.Content;
info.tittle = "Tittle";
avatar.Commit(info);//Commit to cache.
avatar.Push();//Write content to local file.

Demo

  • Demos in the path "MGS.Packages/FileAvatar/Demo/" provide reference to you.

Copyright © 2022 Mogoson. mogoson@outlook.com