예제 #1
0
        public void SaveFile <T>(ILocalFileSpec <T> fileSpec, T data) where T : class
        {
            this.CreateDirectoryIfNotExists(Path.GetDirectoryName(fileSpec.LocalPath));

            var serialized = fileSpec.Serialiser.Serialise(data);

            File.WriteAllText(fileSpec.LocalPath, serialized);
        }
예제 #2
0
        public Option <T> GetFileContent <T>(ILocalFileSpec <T> fileSpec) where T : class
        {
            var cacheFile = new FileInfo(fileSpec.LocalPath);

            if (!cacheFile.Exists)
            {
                return(Option <T> .None);
            }

            return(fileSpec.Serialiser.Deserialise <T>(File.ReadAllText(cacheFile.FullName)));
        }