コード例 #1
0
ファイル: GameModel.cs プロジェクト: CreatingGenres/GameMaker
 public static GameModel Load(SupportedSaveFormats format, StreamReader loadLocation)
 {
     switch (format)
     {
         case SupportedSaveFormats.Json:
             JsonSerializer jsonSerializer = new JsonSerializer();
             return jsonSerializer.Deserialize(loadLocation, typeof(GameModel)) as GameModel;
         case SupportedSaveFormats.Xml:
             XmlSerializer xmlSerializer = new XmlSerializer(typeof(GameModel));
             return xmlSerializer.Deserialize(loadLocation) as GameModel;
         default:
             throw new NotSupportedException("Invalid save format");
     }
 }
コード例 #2
0
ファイル: GameModel.cs プロジェクト: CreatingGenres/GameMaker
        public void SaveAs(SupportedSaveFormats format, StreamWriter saveLocation)
        {
            switch (format)
            {
            case SupportedSaveFormats.Json:
                JsonSerializer jsonSerializer = new JsonSerializer();
                jsonSerializer.Serialize(saveLocation, this);
                break;

            case SupportedSaveFormats.Xml:
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(GameModel));
                xmlSerializer.Serialize(saveLocation, this);
                break;
            }
        }
コード例 #3
0
ファイル: GameModel.cs プロジェクト: CreatingGenres/GameMaker
        public static GameModel Load(SupportedSaveFormats format, StreamReader loadLocation)
        {
            switch (format)
            {
            case SupportedSaveFormats.Json:
                JsonSerializer jsonSerializer = new JsonSerializer();
                return(jsonSerializer.Deserialize(loadLocation, typeof(GameModel)) as GameModel);

            case SupportedSaveFormats.Xml:
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(GameModel));
                return(xmlSerializer.Deserialize(loadLocation) as GameModel);

            default:
                throw new NotSupportedException("Invalid save format");
            }
        }
コード例 #4
0
ファイル: GameModel.cs プロジェクト: CreatingGenres/GameMaker
 public void SaveAs(SupportedSaveFormats format, StreamWriter saveLocation)
 {
     switch (format)
     {
         case SupportedSaveFormats.Json:
             JsonSerializer jsonSerializer = new JsonSerializer();
             jsonSerializer.Serialize(saveLocation, this);
             break;
         case SupportedSaveFormats.Xml:
             XmlSerializer xmlSerializer = new XmlSerializer(typeof(GameModel));
             xmlSerializer.Serialize(saveLocation, this);
             break;
     }
 }