/// <summary> /// Removes the <paramref name="item"/> attribute from the list. /// </summary> /// <param name="item">The attribute to remove.</param> /// <returns><c>true</c> if the attribute was contained by the list and removed; otherwise, <c>false</c>.</returns> public bool Remove(CreateProcessAttribute item) { lock (_attributes) if ((_attributes.TryGetValue(item.GetType(), out var existingItem)) && (Object.ReferenceEquals(existingItem, item))) { _attributes.Remove(item.GetType()); return(true); } return(false); }
/// <summary> /// Adds the <paramref name="item"/> attribute to the attribute list. Any previous item of the same type is replaced. /// </summary> /// <param name="item">The attribute to add.</param> public void Add(CreateProcessAttribute item) { // this type works more like a dictionary, where the key is the item's type than a collection. When an // item is added, any existing item of the same type is removed. We do not attempt to combine items, for // example a InheritHandlesAttribute list will replace, not append, to an existing list. if (item == null) { throw new ArgumentNullException(nameof(item)); } lock (_attributes) _attributes[item.GetType()] = item; }
/// <summary> /// Determines if the <paramref name="item"/> attribute is part of the list. /// </summary> /// <param name="item">The attribute to locate.</param> /// <returns><c>true</c> if the attribute is contained by the list; otherwise, <c>false</c>.</returns> public bool Contains(CreateProcessAttribute item) { if (item == null) { return(false); } lock (_attributes) if ((_attributes.TryGetValue(item.GetType(), out var existingItem)) && (Object.ReferenceEquals(existingItem, item))) { return(true); } return(false); }