Exemplo n.º 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);
        }
Exemplo n.º 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);
        }