Exemple #1
0
        public static XDocument ReadXml(string path)
        {
            var lastWriteTimeUtc = FileSystemHelpers.GetLastWriteTimeUtc(path);

            if (!_fileContentCaches.TryGetValue(path, out FileContentCache cache) ||
                cache.LastWriteTimeUtc < lastWriteTimeUtc)
            {
                cache = new FileContentCache(path, lastWriteTimeUtc, isXml: true);
                _fileContentCaches.AddOrUpdate(path, cache, (_, __) => cache);
            }

            return(cache.Xml);
        }
Exemple #2
0
        public static string ReadAllText(string path)
        {
            var lastWriteTimeUtc = FileSystemHelpers.GetLastWriteTimeUtc(path);

            if (!_fileContentCaches.TryGetValue(path, out FileContentCache cache) ||
                cache.LastWriteTimeUtc < lastWriteTimeUtc)
            {
                cache = new FileContentCache(path, lastWriteTimeUtc);
                _fileContentCaches.AddOrUpdate(path, cache, (_, __) => cache);
            }

            return(cache.Content);
        }