/// <summary> /// Fetches the document from the folder path. /// </summary> /// <param name="path">The path.</param> /// <param name="adapter">The storage adapter where the document can be found.</param> /// <param name="forceReload">If true, reload the object from file and replace the current object with it.</param> /// <returns>The <see cref="CdmDocumentDefinition"/>.</returns> internal async Task <CdmDocumentDefinition> FetchDocumentFromFolderPathAsync(string objectPath, StorageAdapter adapter, bool forceReload = false) { string docName; string remainingPath; int first = objectPath.IndexOf('/', 0); if (first < 0) { remainingPath = ""; docName = objectPath; } else { remainingPath = objectPath.Slice(first + 1); docName = objectPath.Substring(0, first); } // got that doc? CdmDocumentDefinition doc = null; if (this.DocumentLookup.ContainsKey(docName)) { doc = this.DocumentLookup[docName]; if (!forceReload) { return(doc); } // remove them from the caches since they will be back in a moment if ((doc as CdmDocumentDefinition).IsDirty) { Logger.Warning(nameof(CdmFolderDefinition), this.Ctx, $"discarding changes in document: {doc.Name}"); } this.Documents.Remove(docName); } // go get the doc doc = await PersistenceLayer.LoadDocumentFromPathAsync(this, docName, doc); return(doc); }