Exemplo n.º 1
0
        /// <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));
        }
Exemplo n.º 2
0
        /// <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));
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
 /// <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));
 }
Exemplo n.º 6
0
		/// <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);
		}
Exemplo n.º 7
0
		/// <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);
		}
Exemplo n.º 8
0
        /// <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;
        }
Exemplo n.º 9
0
		/// <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;
		}
Exemplo n.º 10
0
		/// <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;
		}
Exemplo n.º 11
0
		/// <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);
		}
Exemplo n.º 12
0
		/// <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);
		}