Ejemplo n.º 1
0
        public RestBoxState RemoveRestBoxStateFile(RestBoxStateFile restBoxStateFile)
        {
            if (!fileService.FileExists(stateFileLocation))
            {
                return null;
            }

            var restBoxState = fileService.Load<RestBoxState>(stateFileLocation);

            for (var i = restBoxState.RestBoxStateFiles.Count - 1; i >= 0; i--)
            {
                if (restBoxState.RestBoxStateFiles[i].FilePath == restBoxStateFile.FilePath)
                {
                    restBoxState.RestBoxStateFiles.RemoveAt(i);
                }
            }

            restBoxState.RestBoxStateFiles = restBoxState.RestBoxStateFiles.Take(10).ToList();

            fileService.SaveFile(stateFileLocation, jsonSerializer.ToJsonString(restBoxState));

            return restBoxState;
        }
Ejemplo n.º 2
0
        public void SaveState(RestBoxStateFile restBoxStateFile)
        {
            var restBoxState = new RestBoxState();

            if (fileService.FileExists(stateFileLocation))
            {
                restBoxState = fileService.Load<RestBoxState>(stateFileLocation);
            }

            for (var i = restBoxState.RestBoxStateFiles.Count - 1; i >= 0; i--)
            {
                if (restBoxState.RestBoxStateFiles[i].FilePath == restBoxStateFile.FilePath)
                {
                    restBoxState.RestBoxStateFiles.RemoveAt(i);
                }
            }

            restBoxState.RestBoxStateFiles.Insert(0, restBoxStateFile);

            restBoxState.RestBoxStateFiles = restBoxState.RestBoxStateFiles.Take(10).ToList();

            fileService.SaveFile(stateFileLocation, jsonSerializer.ToJsonString(restBoxState));
        }
Ejemplo n.º 3
0
 private void SaveRestBoxState(RestBoxStateFile restBoxStateFile)
 {
     restBoxStateService.SaveState(restBoxStateFile);
 }