Exemple #1
0
        public Result SetState(ulong saveDataId, SaveDataState state)
        {
            // Nintendo doesn't lock in this function for some reason
            lock (Locker)
            {
                if (IsKeyValueSet && _value.SaveDataId == saveDataId)
                {
                    _value.State = state;
                    return(Result.Success);
                }

                return(ResultFs.TargetNotFound.Log());
            }
        }
Exemple #2
0
        public void Save(List <Transaction> transactions, string path = "./output/LastState.mdb")
        {
            var state = new SaveDataState()
            {
                Transactions = transactions, LastModification = DateTime.Now
            };
            var jsonText = JsonConvert.SerializeObject(state);

            var file = new FileInfo(path);

            if (!file.Directory.Exists)
            {
                file.Directory.Create();
            }

            using (var sw = new StreamWriter(file.FullName, false))
            {
                sw.Write(jsonText);
                sw.Flush();
            }
            File.Copy(file.FullName, Path.Combine(file.Directory.FullName, "state_" + DateTime.Now.Ticks + ".mdb"));
        }