예제 #1
0
        /// <summary>
        /// Gets or sets the value held by the column whose table and column names are given.
        /// <para>The setter creates dynamically an entry for the given column specification.</para>
        /// </summary>
        /// <param name="table">The table name of the entry to find, or null to refer to the
        /// default one in this context.</param>
        /// <param name="column">The column name.</param>
        /// <returns>The value held by the requested entry.</returns>
        public object this[string table, string column]
        {
            get
            {
                if (IsDisposed)
                {
                    throw new ObjectDisposedException(this.ToString());
                }
                table  = SchemaEntry.ValidateTable(table);
                column = SchemaEntry.ValidateColumn(column);

                var entry = _Schema.FindEntry(table, column);
                if (entry == null)
                {
                    throw new NotFoundException(
                              "Entry '{0}' not found in this '{1}'".FormatWith(SchemaEntry.NormalizedName(table, column), this));
                }

                var index = _Schema.IndexOf(entry);
                return(_Values[index]);
            }
            set
            {
                if (IsDisposed)
                {
                    throw new ObjectDisposedException(this.ToString());
                }
                table  = SchemaEntry.ValidateTable(table);
                column = SchemaEntry.ValidateColumn(column);

                var entry = _Schema.FindEntry(table, column); if (entry == null)
                {
                    _Schema.AddCreate(table, column);
                    _Values.Add(value);
                }
                else
                {
                    var index = _Schema.IndexOf(entry);
                    _Values[index] = value;
                }
            }
        }