public DocumentCache CreateCache(string documentDirectoryPath, string templateDirectoryPath) { // Normalize the paths for comparison purposes. var normalizedDocumentDirectoryPath = Path.GetFullPath(documentDirectoryPath).TrimEnd('\\'); var normalizedTemplateDirectoryPath = Path.GetFullPath(templateDirectoryPath).TrimEnd('\\'); // Only allow one DocumentCache per document directory. if (documentDirectoryPaths.Contains(documentDirectoryPath)) { throw new InvalidOperationException("There is already a DocumentCache for this document directory."); } DocumentCache documentCache; if (this.DefaultDocumentLifespan == TimeSpan.Zero) { documentCache = new DocumentCache(normalizedDocumentDirectoryPath, normalizedTemplateDirectoryPath); } else { documentCache = new DocumentCache(normalizedDocumentDirectoryPath, normalizedTemplateDirectoryPath, this.DefaultDocumentLifespan); } documentDirectoryPaths.Add(normalizedDocumentDirectoryPath); return(documentCache); }
public DocumentCache CreateCache(string documentDirectoryPath, string templateDirectoryPath) { // Normalize the paths for comparison purposes. var normalizedDocumentDirectoryPath = Path.GetFullPath(documentDirectoryPath).TrimEnd('\\'); var normalizedTemplateDirectoryPath = Path.GetFullPath(templateDirectoryPath).TrimEnd('\\'); // Only allow one DocumentCache per document directory. if (documentDirectoryPaths.Contains(documentDirectoryPath)) { throw new InvalidOperationException("There is already a DocumentCache for this document directory."); } DocumentCache documentCache; if (this.DefaultDocumentLifespan == TimeSpan.Zero) { documentCache = new DocumentCache(normalizedDocumentDirectoryPath, normalizedTemplateDirectoryPath); } else { documentCache = new DocumentCache(normalizedDocumentDirectoryPath, normalizedTemplateDirectoryPath, this.DefaultDocumentLifespan); } documentDirectoryPaths.Add(normalizedDocumentDirectoryPath); return documentCache; }