public void SetUp() { obj = new PublicSafetyDrug(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()); obj.Description = "data"; obj.Serial = "data1"; lst = new List <PublicSafetyDrug>(); lst.Add(obj); itemCollection = new ManagedCollection <PublicSafetyDrug>(lst); }
public void CopyTo(TValue[] array, int arrayIndex) { if ((validOperations & Operations.CopyTo) == Operations.CopyTo) { OnAccessed(); ManagedCollection.CopyTo(array, arrayIndex); } else { throw new NotSupportedException($"A process attempted to copy a {NameOf<Conservator<TValue>>()} " + $"whose list of supported operations does not include " + $"{nameof(Operations)}.{Operations.CopyTo}. "); } }
public void Clear() { if ((validOperations & Operations.Clear) == Operations.Clear) { ManagedCollection.Clear(); OnModified(); } else { throw new NotSupportedException($"A process attempted to clear a {NameOf<Conservator<TValue>>()} " + $"whose list of supported operations does not include " + $"{nameof(Operations)}.{Operations.Clear}. "); } }
public void Add(TValue item) { if ((validOperations & Operations.Add) == Operations.Add) { ManagedCollection.Add(item); OnModified(); } else { throw new NotSupportedException($"A process attempted to add an element to a {NameOf<Conservator<TValue>>()} " + $"whose list of supported operations does not include " + $"{nameof(Operations)}.{Operations.CopyTo}. "); } }
public bool Remove(TValue item) { if ((validOperations & Operations.Remove) == Operations.Remove) { bool result = ManagedCollection.Remove(item); OnModified(); return(result); } else { throw new NotSupportedException($"A process attempted to remove an element from a {NameOf<Conservator<TValue>>()} " + $"whose list of supported operations does not include " + $"{nameof(Operations)}.{Operations.Remove}. "); } }
public async Task Initilize(IEnumerable <IFileChain> chain) { IEnumerable <ManagedCollection> collections = (await Task.WhenAll( chain.Select(async x => { ICollection toClone = await x.Root.Task; if (toClone == null) { return(null); } else { return(await toClone?.CloneManagedAsync(this, FileSystem)); } })) ).Where(x => x != null).Reverse(); ManagedCollection root = collections.First(); foreach (ManagedCollection mc in collections.Skip(1)) { //TODO: diff-add file structure trees } Queue <ManagedCollection> colQueue = new Queue <ManagedCollection>(); colQueue.Enqueue(root); CollectionFastAccess.Add(root.Name, root); ManagedCollection deq = null; while (colQueue.Count > 0 && (deq = colQueue.Dequeue()) != null) { foreach (ManagedCollection col in deq.Collections) { CollectionFastAccess.Add(Uri.UnescapeDataString(col.Path.OriginalString), col); colQueue.Enqueue(col); } foreach (ManagedDocument doc in deq.Documents) { DocumentFastAccess.Add(Uri.UnescapeDataString(doc.Path.OriginalString), doc); } } Root = root; }
public async Task <SelectionResult> SelectAsync(string path, CancellationToken ct) { if (string.IsNullOrEmpty(path)) { return(SelectionResult.Create(CollectionFastAccess[path])); } else if (CollectionFastAccess.ContainsKey(path)) { return(SelectionResult.Create(CollectionFastAccess[path])); } else if (CollectionFastAccess.ContainsKey(path + '\\')) { return(SelectionResult.Create(CollectionFastAccess[path + '\\'])); } else if (CollectionFastAccess.ContainsKey(path + '/')) { return(SelectionResult.Create(CollectionFastAccess[path + '/'])); } else if (DocumentFastAccess.ContainsKey(path)) { ManagedDocument manDoc = DocumentFastAccess[path]; return(SelectionResult.Create(manDoc.Parent, manDoc)); } else { string[] pathParts = path.Split('\\', '/'); int i = 0; ManagedCollection mc = Root; for (; i < pathParts.Length; i++) { ManagedCollection nmc = mc.Collections.Where(x => x.Name.Equals(pathParts[i])).SingleOrDefault(); if (nmc == null) { break; } mc = nmc; } return(SelectionResult.CreateMissingDocumentOrCollection(mc, new ArraySegment <string>(pathParts, i, pathParts.Length - i))); } }
public Task <DeleteResult> DeleteAsync(ManagedCollection entry, CancellationToken ct) { ((ManagedCollection)entry.Parent).Collections.Remove(entry); return(FileSystem.DeleteAsync(entry, ct)); }
public async Task <IDocument> CreateDocumentAsync(ManagedCollection entry, string name, CancellationToken ct) { IDocument added = await FileSystem.CreateDocumentAsync(entry, name, ct); return(await added.CloneManagedAsync(this, FileSystem, entry)); }
public bool Contains(TValue item) { OnAccessed(); return(ManagedCollection.Contains(item)); }
public void Constructor() { itemCollection = new ManagedCollection <PublicSafetyDrug>(null); }