public async Task <IDocument> CopyToAsync(ICollection collection, string name, CancellationToken ct) { ManagedDocument doc = await(await Manager.CopyToAsync(this, collection, name, ct)).CloneManagedAsync(Manager, _FileSystem, collection as ManagedCollection); Manager.DocumentFastAccess.Add(doc.PathName, doc); return(doc); //return Manager.CopyToAsync(this, collection, name, cancellationToken); }
public static Task <ManagedDocument> CloneManagedAsync(this IDocument document, IFileSystemStructureManager manager, IChainedFileSystem fileSystem, ManagedCollection parent = null) { if (document is ManagedDocument) { return(Task.FromResult((ManagedDocument)document)); } ManagedDocument ret = new ManagedDocument(); ret.Manager = manager; ret.Name = document.Name; ret._FileSystem = fileSystem; // ret._Parent = parent; // ret.Path = document.Path; ret.LastWriteTimeUtc = document.LastWriteTimeUtc; ret.CreationTimeUtc = document.CreationTimeUtc; ret.Length = document.Length; parent.Documents.Add(ret); manager.DocumentFastAccess.Add(Uri.UnescapeDataString(ret.Path.OriginalString), ret); return(Task.FromResult(ret)); }