Esempio n. 1
0
        /// <summary>
        /// Invoked when a get memebr operation is resolved dynamically.
        /// </summary>
        /// <param name="binder">Provides information about the operation to execute.</param>
        /// <param name="result">Holder for the result of the operation.</param>
        /// <returns>True if the operation executed successfully, false otherwise.</returns>
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }
            if (_Schema == null)
            {
                throw new InvalidOperationException("This '{0}' is not associated with any schema.".FormatWith(this));
            }

            var list = _Schema.FindTable(binder.Name).ToList(); if (list.Count != 0)

            {
                result = new RecordResolver(this, binder.Name); list.Clear(); list = null;
                return(true);
            }

            list = _Schema.FindColumn(binder.Name).ToList(); if (list.Count == 1)
            {
                result = this[binder.Name]; list.Clear(); list = null;
                return(true);
            }
            if (list.Count == 0)
            {
                throw new NotFoundException("Column '{0}' not found.".FormatWith(binder.Name));
            }
            throw new DuplicateException("Dynamic name '{0}' found in several columns in '{1}'.".FormatWith(binder.Name, list.Sketch()));
        }
Esempio n. 2
0
		/// <summary>
		/// Invoked when a get memebr operation is resolved dynamically.
		/// </summary>
		/// <param name="binder">Provides information about the operation to execute.</param>
		/// <param name="result">Holder for the result of the operation.</param>
		/// <returns>True if the operation executed successfully, false otherwise.</returns>
		public override bool TryGetMember(GetMemberBinder binder, out object result)
		{
			if (IsDisposed) throw new ObjectDisposedException(this.ToString());
			if (_Schema == null) throw new InvalidOperationException("This '{0}' is not associated with any schema.".FormatWith(this));

			var list = _Schema.FindTable(binder.Name).ToList(); if (list.Count != 0)
			{
				result = new RecordResolver(this, binder.Name); list.Clear(); list = null;
				return true;
			}

			list = _Schema.FindColumn(binder.Name).ToList(); if (list.Count == 1)
			{
				result = this[binder.Name]; list.Clear(); list = null;
				return true;
			}
			if (list.Count == 0) throw new NotFoundException("Column '{0}' not found.".FormatWith(binder.Name));
			throw new DuplicateException("Dynamic name '{0}' found in several columns in '{1}'.".FormatWith(binder.Name, list.Sketch()));
		}