/// <summary> /// Returns the index at which the given member is stored, or -1 if it does not belong /// to this collection. /// </summary> /// <param name="member">The member whose index if to be found.</param> /// <returns>The index at which the given member is stored, or -1 if it does not belong /// to this collection.</returns> public int IndexOf(IElementAlias member) { if (IsDisposed) { throw new ObjectDisposedException(this.ToString()); } if (member == null) { throw new ArgumentNullException("member", "Member cannot be null."); } return(_Members.IndexOf(member)); }
/// <summary> /// Returns whether the given member is in this collection. /// </summary> /// <param name="member">The member to validate.</param> /// <returns>True if the given member is part of this collection, or false otherwise.</returns> public bool Contains(IElementAlias member) { if (IsDisposed) { throw new ObjectDisposedException(this.ToString()); } if (member == null) { throw new ArgumentNullException("Member cannot be null."); } return(_Members.Contains(member)); }
/// <summary> /// Removes the given parameter from this collection. Returns true if it has been removed /// succesfully, or false otherwise. /// </summary> /// <param name="member">The member to remove.</param> /// <returns>True if the member has been removed succesfully, or false otherwise.</returns> public bool Remove(IElementAlias member) { if (IsDisposed) { throw new ObjectDisposedException(this.ToString()); } if (member == null) { throw new ArgumentNullException("member", "Member cannot be null."); } // If r is false intercepts re-entrant operations... bool r = _Members.Remove(member); if (r) { member.Owner = null; } return(r); }
/// <summary> /// Returns true if this object can be considered as equivalent to the target one given. /// </summary> /// <param name="target">The target object this one will be tested for equivalence.</param> /// <returns>True if this object can be considered as equivalent to the target one given.</returns> public bool EquivalentTo(IElementAlias target) { return OnEquivalentTo(target); }
/// <summary> /// Adds the given orphan instance into this collection. /// </summary> /// <param name="member">The orphan instance to add into this collection.</param> public void Add(IElementAlias member) { if (IsDisposed) { throw new ObjectDisposedException(this.ToString()); } if (member == null) { throw new ArgumentNullException("member", "Member cannot be null."); } if (member.IsDisposed) { throw new ObjectDisposedException(member.ToString()); } if (object.ReferenceEquals(this, member.Owner)) { return; } if (member.Owner != null) { throw new NotOrphanException( "Cannot add member '{0}' into this '{1}' because it is not orphan." .FormatWith(member, this)); } Core.ElementAlias.ValidateElement(member.Element); Core.ElementAlias.ValidateAlias(member.Alias); var temp = FindAlias(member.Alias); if (temp != null) { throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its alias is already used." .FormatWith(member, this)); } var list = FindElement(member.Alias).ToList(); if (list.Count != 0) { throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its alias is used as an element name." .FormatWith(member, this)); } if (member.Element != null) { temp = FindAlias(member.Element); if (temp != null) { throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its element is already used as an alias." .FormatWith(member, this)); } } _Members.Add(member); // To intercept re-entrant operation... member.Owner = this; }
/// <summary> /// Removes the given parameter from this collection. Returns true if it has been removed /// succesfully, or false otherwise. /// </summary> /// <param name="member">The member to remove.</param> /// <returns>True if the member has been removed succesfully, or false otherwise.</returns> public bool Remove(IElementAlias member) { if (IsDisposed) throw new ObjectDisposedException(this.ToString()); if (member == null) throw new ArgumentNullException("member", "Member cannot be null."); // If r is false intercepts re-entrant operations... bool r = _Members.Remove(member); if (r) member.Owner = null; return r; }
/// <summary> /// Adds the given orphan instance into this collection. /// </summary> /// <param name="member">The orphan instance to add into this collection.</param> public void Add(IElementAlias member) { if (IsDisposed) throw new ObjectDisposedException(this.ToString()); if (member == null) throw new ArgumentNullException("member", "Member cannot be null."); if (member.IsDisposed) throw new ObjectDisposedException(member.ToString()); if (object.ReferenceEquals(this, member.Owner)) return; if (member.Owner != null) throw new NotOrphanException( "Cannot add member '{0}' into this '{1}' because it is not orphan." .FormatWith(member, this)); Core.ElementAlias.ValidateElement(member.Element); Core.ElementAlias.ValidateAlias(member.Alias); var temp = FindAlias(member.Alias); if (temp != null) throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its alias is already used." .FormatWith(member, this)); var list = FindElement(member.Alias).ToList(); if (list.Count != 0) throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its alias is used as an element name." .FormatWith(member, this)); if (member.Element != null) { temp = FindAlias(member.Element); if (temp != null) throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its element is already used as an alias." .FormatWith(member, this)); } _Members.Add(member); // To intercept re-entrant operation... member.Owner = this; }
/// <summary> /// Returns whether the given member is in this collection. /// </summary> /// <param name="member">The member to validate.</param> /// <returns>True if the given member is part of this collection, or false otherwise.</returns> public bool Contains(IElementAlias member) { if (IsDisposed) throw new ObjectDisposedException(this.ToString()); if (member == null) throw new ArgumentNullException("Member cannot be null."); return _Members.Contains(member); }
/// <summary> /// Returns the index at which the given member is stored, or -1 if it does not belong /// to this collection. /// </summary> /// <param name="member">The member whose index if to be found.</param> /// <returns>The index at which the given member is stored, or -1 if it does not belong /// to this collection.</returns> public int IndexOf(IElementAlias member) { if (IsDisposed) throw new ObjectDisposedException(this.ToString()); if (member == null) throw new ArgumentNullException("member", "Member cannot be null."); return _Members.IndexOf(member); }
/// <summary> /// Returns true if this object can be considered as equivalent to the target one given. /// </summary> /// <param name="target">The target object this one will be tested for equivalence.</param> /// <returns>True if this object can be considered as equivalent to the target one given.</returns> public bool EquivalentTo(IElementAlias target) { return(OnEquivalentTo(target)); }