public ManagedCollection(IFileSystemStructureManager manager, string name, IChainedFileSystem fileSystem, ManagedCollection parent, Uri path, DateTime lastWriteTimeUtc, DateTime creationTimeUtc) : this() { Manager = manager; Name = name; _FileSystem = fileSystem; _Parent = parent; Path = path; LastWriteTimeUtc = lastWriteTimeUtc; CreationTimeUtc = creationTimeUtc; }
public static async Task <ManagedCollection> CloneManagedAsync(this ICollection collection, IFileSystemStructureManager manager, IChainedFileSystem fileSystem, ManagedCollection parent = null) { if (collection is ManagedCollection) { return((ManagedCollection)collection); } ManagedCollection ret = new ManagedCollection(); ret.Manager = manager; ret.Name = collection.Name; ret._FileSystem = fileSystem; // ret._Parent = parent; // ret.Path = collection.Path; ret.LastWriteTimeUtc = collection.LastWriteTimeUtc; ret.CreationTimeUtc = collection.CreationTimeUtc; ret.Collections = new LinkedList <ManagedCollection>(); ret.Documents = new LinkedList <ManagedDocument>(); IReadOnlyCollection <IEntry> entries = await collection.GetChildrenAsync(new CancellationToken()); List <Task> ts = new List <Task>(entries.Count); foreach (IEntry e in entries) { if (e is ICollection) { ts.Add(((ICollection)e).CloneManagedAsync(manager, fileSystem, ret)); } else { ts.Add(((IDocument)e).CloneManagedAsync(manager, fileSystem, ret)); } } Task.WaitAll(ts.ToArray()); parent?.Collections.Add(ret); manager.CollectionFastAccess.Add(Uri.UnescapeDataString(ret.Path.OriginalString), ret); return(ret); }
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)); }