/// <summary>The load.</summary> public void Load() { try { var fileName = new FileInfo(this.absolutePath); if (fileName.Exists) { this.cachedSection = ReadOnlyCacheSection.Load(fileName.FullName, this.context); this.isUnsaved = this.cachedSection != null; } } catch (PathTooLongException ex) { throw new BuildWorkflowException("Path to long: {0}".InvariantFormat(this.absolutePath), ex); } }
/// <summary>The load.</summary> /// <param name="fullPath">The full path.</param> /// <param name="context">The context.</param> /// <returns>The <see cref="CacheSection"/>.</returns> internal static ReadOnlyCacheSection Load(string fullPath, IWebGreaseContext context) { if (!File.Exists(fullPath)) { return(null); } return(Safe.Lock(LoadLock, () => { ReadOnlyCacheSection cacheSection; if (!context.Cache.LoadedCacheSections.TryGetValue(fullPath, out cacheSection)) { cacheSection = new ReadOnlyCacheSection(File.ReadAllText(fullPath), context); context.Cache.LoadedCacheSections.Add(fullPath, cacheSection); } cacheSection.referenceCount++; return cacheSection; })); }