示例#1
0
        public TripContext(string fileDBLocation)
        {
            _fileDBLocation = fileDBLocation;

            var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("");

            IFileInfo fi;

            if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi))
            {
                var json   = File.ReadAllText(fi.PhysicalPath);
                var result = JsonConvert.DeserializeObject <List <Trip> >(json);

                Trips = result.ToList();
            }
        }
示例#2
0
        public TripContext(string fileDBLocation)
        {
            _fileDBLocation = fileDBLocation;

            var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("");

            IFileInfo fi;
            if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi))
            {

                var json = File.ReadAllText(fi.PhysicalPath);
                var result = JsonConvert.DeserializeObject<List<Trip>>(json);

                Trips = result.ToList();
            }
        }
        public bool SaveChanges()
        {
            // write trips to json file, overwriting the old one

            var json = JsonConvert.SerializeObject(Trips);

            var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("");

            IFileInfo fi;
            if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi))
            {
                File.WriteAllText(fi.PhysicalPath, json);
                return true;
            }

            return false;
        }
示例#4
0
        public bool SaveChanges()
        {
            // write trips to json file, overwriting the old one

            var json = JsonConvert.SerializeObject(Trips);

            var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("");

            IFileInfo fi;

            if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi))
            {
                File.WriteAllText(fi.PhysicalPath, json);
                return(true);
            }

            return(false);
        }
示例#5
0
        private IFileInfo GetJsonFile()
        {
            var fileSystem = new PhysicalFileSystem("");

            IFileInfo fileInfo;
            fileSystem.TryGetFileInfo(_jsonFileLocation, out fileInfo);

            return fileInfo;
        }