/// <summary> /// Adds the specified compound. /// </summary> /// <param name="compound">The compound to add.</param> public void AddCompound(INCompound compound) { if (HasCompound(compound)) { return; } compound.SetParent(Owner); Add(compound); OnCompoundAdded(new CompoundAddedEventArgs(this, compound)); }
/// <summary> /// Finds and returns a compound with the specified name. /// </summary> /// <param name="compoundName">The name of the compound to find.</param> /// <param name="result">The resulting compound.</param> /// <returns><c>true</c> if the compound was found; otherwise, <c>false</c>.</returns> public bool TryGetCompound(string compoundName, out INCompound result) { if (!TryGetItem(compoundName, out var c)) { result = null; return(false); } if (!(c is INCompound compound)) { result = null; return(false); } result = compound; return(true); }
/// <summary> /// Returns a value indicating whether the specified compound exists. /// </summary> /// <param name="compound">The compound to find.</param> /// <returns><c>true</c> if the compound was found; otherwise, <c>false</c>.</returns> public bool HasCompound(INCompound compound) { return(HasCompound(compound.Name)); }
public CompoundAddedEventArgs([NotNull] INItemCollection collection, [NotNull] INCompound compound) : base(collection) { Compound = compound; }