/// <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(ISchemaEntry 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(ISchemaEntry 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(ISchemaEntry 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 into this builder a new entry using the given one, optionally cloning it, along /// with the value to be held by its associated column. /// </summary> /// <param name="entry">The schema entry.</param> /// <param name="value">The value of the column.</param> /// <param name="cloneEntry">True to clone the given entry</param> public void AddEntry(ISchemaEntry entry, object value, bool cloneEntry = true) { if (IsDisposed) { throw new ObjectDisposedException(this.ToString()); } if (entry == null) { throw new ArgumentNullException("entry", "Entry cannot be null."); } if (entry.IsDisposed) { throw new ObjectDisposedException(entry.ToString()); } if (cloneEntry) { entry = entry.Clone(); } _Schema.Add(entry); _Values.Add(value); }
/// <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(ISchemaEntry target) { return(OnEquivalentTo(target)); }
/// <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(ISchemaEntry target) { return OnEquivalentTo(target); }
/// <summary> /// Adds into this builder a new entry using the given one, optionally cloning it, along /// with the value to be held by its associated column. /// </summary> /// <param name="entry">The schema entry.</param> /// <param name="value">The value of the column.</param> /// <param name="cloneEntry">True to clone the given entry</param> public void AddEntry(ISchemaEntry entry, object value, bool cloneEntry = true) { if (IsDisposed) throw new ObjectDisposedException(this.ToString()); if (entry == null) throw new ArgumentNullException("entry", "Entry cannot be null."); if (entry.IsDisposed) throw new ObjectDisposedException(entry.ToString()); if (cloneEntry) entry = entry.Clone(); _Schema.Add(entry); _Values.Add(value); }
/// <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(ISchemaEntry 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.SchemaEntry.ValidateTable(member.TableName); Core.SchemaEntry.ValidateColumn(member.ColumnName); var alias = (IElementAlias)(member.TableName == null ? null : Aliases.FindAlias(member.TableName)); if (alias != null) { member.TableName = alias.Element; } var temp = FindEntry(member.TableName, member.ColumnName); if (temp != null) { throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its name is already used." .FormatWith(member, this)); } var list = FindColumn(member.ColumnName).ToList(); if (list.Count != 0) { if (member.TableName == null) { throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its column is already used in a non-default table." .FormatWith(member, this)); } temp = list.Find(x => x.TableName == null); if (temp != null) { throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its name is already used in the default table." .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(ISchemaEntry 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(ISchemaEntry 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.SchemaEntry.ValidateTable(member.TableName); Core.SchemaEntry.ValidateColumn(member.ColumnName); var alias = (IElementAlias)(member.TableName == null ? null : Aliases.FindAlias(member.TableName)); if (alias != null) member.TableName = alias.Element; var temp = FindEntry(member.TableName, member.ColumnName); if (temp != null) throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its name is already used." .FormatWith(member, this)); var list = FindColumn(member.ColumnName).ToList(); if (list.Count != 0) { if (member.TableName == null) throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its column is already used in a non-default table." .FormatWith(member, this)); temp = list.Find(x => x.TableName == null); if (temp != null) throw new DuplicateException( "Cannot add member '{0}' into this '{1}' because its name is already used in the default table." .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(ISchemaEntry 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(ISchemaEntry member) { if (IsDisposed) throw new ObjectDisposedException(this.ToString()); if (member == null) throw new ArgumentNullException("member", "Member cannot be null."); return _Members.IndexOf(member); }