Esempio n. 1
0
        private int IndexOf(string name, bool error)
        {
            // exact case matching has already be done by the caller
            // Get existing doublet
            Doublet d = (Doublet)columnNameCount [name];

            if (d != null)
            {
                if (d.count == 1)
                {
                    // There's only one
                    // return index of the column from the only column name of the doublet
                    return(base.List.IndexOf(columnFromName [d.columnNames [0]]));
                }
                else if (d.count > 1 && error)
                {
                    // there's more than one, exception!
                    throw new ArgumentException("There is no match for '" + name + "' in the same case and there are multiple matches in different case.");
                }
                else
                {
                    return(-1);
                }
            }
            return(-1);
        }
Esempio n. 2
0
        internal void UnregisterName(string name)
        {
            if (columnFromName.Contains(name))
            {
                columnFromName.Remove(name);
            }

            // Get the existing doublet
            Doublet d = (Doublet)columnNameCount [name];

            if (d != null)
            {
                // decrease reference count
                d.count--;
                d.columnNames.Remove(name);
                // remove doublet if no more references
                if (d.count == 0)
                {
                    columnNameCount.Remove(name);
                }
            }

            if (name.StartsWith(ColumnPrefix) && name == MakeName(defaultColumnIndex - 1))
            {
                do
                {
                    defaultColumnIndex--;
                } while (!Contains(MakeName(defaultColumnIndex - 1)) && defaultColumnIndex > 1);
            }
        }
Esempio n. 3
0
        internal void RegisterName(string name, DataColumn column)
        {
            if (columnFromName.Contains(name))
            {
                throw new DuplicateNameException("A DataColumn named '" + name + "' already belongs to this DataTable.");
            }

            columnFromName[name] = column;
            // Get existing doublet
            Doublet d = (Doublet)columnNameCount[name];

            if (d != null)
            {
                // Add reference count
                d.count++;
                // Add a new name
                d.columnNames.Add(name);
            }
            else
            {
                // no existing doublet
                // create one
                d = new Doublet(1, name);
                columnNameCount[name] = d;
            }

            if (name.StartsWith("Column") && name == MakeName(defaultColumnIndex + 1))
            {
                do
                {
                    defaultColumnIndex++;
                }while (Contains(MakeName(defaultColumnIndex + 1)));
            }
        }
Esempio n. 4
0
        internal void RegisterName(string name, DataColumn column)
        {
            try
            {
                columnFromName.Add(name, column);
            }
            catch (ArgumentException)
            {
                throw new DuplicateNameException("A DataColumn named '" + name + "' already belongs to this DataTable.");
            }

            // Get existing doublet
            Doublet d = (Doublet)columnNameCount [name];

            if (d != null)
            {
                // Add reference count
                d.count++;
                // Add a new name
                d.columnNames.Add(name);
            }
            else
            {
                // no existing doublet
                // create one
                d = new Doublet(1, name);
                columnNameCount [name] = d;
            }

#if NET_2_0
            if (name.Length <= ColumnPrefix.Length || !name.StartsWith(ColumnPrefix, StringComparison.Ordinal))
            {
                return;
            }
#else
            if (name.Length <= ColumnPrefix.Length || !name.StartsWith(ColumnPrefix))
            {
                return;
            }
#endif

            if (name == MakeName(defaultColumnIndex + 1))
            {
                do
                {
                    defaultColumnIndex++;
                }while (Contains(MakeName(defaultColumnIndex + 1)));
            }
        }
Esempio n. 5
0
		internal void RegisterName (string name, DataColumn column)
		{
			try {
				columnFromName.Add (name, column);
			} catch (ArgumentException) {
				throw new DuplicateNameException ("A DataColumn named '" + name + "' already belongs to this DataTable.");
			}

			// Get existing doublet
			Doublet d = (Doublet) columnNameCount [name];
			if (d != null) {
				// Add reference count
				d.count++;
				// Add a new name
				d.columnNames.Add (name);
			} else {
				// no existing doublet
				// create one
				d = new Doublet (1, name);
				columnNameCount [name] = d;
			}

			if (name.Length <= ColumnPrefix.Length || !name.StartsWith (ColumnPrefix, StringComparison.Ordinal))
				return;

			if (name == MakeName (defaultColumnIndex + 1)) {
				do {
					defaultColumnIndex++;
				} while (Contains (MakeName (defaultColumnIndex + 1)));
			}
		}