Exemplo n.º 1
0
        /// <summary>
        /// Returns the string representation of this instance.
        /// </summary>
        /// <returns>A string containing the standard representation of this instance.</returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("["); if (_Values != null)
            {
                for (int i = 0; i < _Values.Count; i++)
                {
                    if (i != 0)
                    {
                        sb.Append(", ");
                    }

                    var value = _Values[i].Sketch();
                    var name  = SchemaEntry.NormalizedName(_Schema[i].TableName, _Schema[i].ColumnName);

                    sb.AppendFormat("{0} = '{1}'", name, value);
                }
            }

            sb.Append("]");

            var str = sb.ToString();

            return(IsDisposed ? string.Format("disposed::{0}({1})", GetType().EasyName(), str) : str);
        }
Exemplo n.º 2
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;
                }
            }
        }