예제 #1
0
        private void FireSelectingEvent(ObjectContainerDataSourceSelectingEventArgs selectingEventArgs)
        {
            bool handled = OnSelecting(selectingEventArgs);

            if (!handled && UsingServerPaging)
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.UsingServerPagingAndSelectingEventNotHandled));
            }
        }
예제 #2
0
        /// <summary>
        /// Fires the <see cref="ObjectContainerDataSourceView.Selecting"/> event.
        /// </summary>
        /// <param name="e">The event associated data.</param>
        protected virtual bool OnSelecting(ObjectContainerDataSourceSelectingEventArgs e)
        {
            EventHandler <ObjectContainerDataSourceSelectingEventArgs> handler =
                base.Events[SelectingEventKey] as EventHandler <ObjectContainerDataSourceSelectingEventArgs>;

            if (handler != null)
            {
                handler(this, e);
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        /// <summary>
        /// Gets a list of data from the underlying data storage.
        /// </summary>
        /// <param name="arguments">A <see cref="DataSourceSelectArguments"/> that is used to request operations on the data
        /// beyond basic data retrieval.</param>
        /// <returns>An <see cref="IEnumerable"/> list of data from the underlying data storage.</returns>
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            AddSupportedCapabilities(arguments);

            ObjectContainerDataSourceSelectingEventArgs selectingEventArgs = new ObjectContainerDataSourceSelectingEventArgs(arguments);

            FireSelectingEvent(selectingEventArgs);
            if (selectingEventArgs.Cancel)
            {
                return(null);
            }

            SortDataForSelectIfNeeded(arguments);

            if (arguments.RetrieveTotalRowCount)
            {
                arguments.TotalRowCount = _totalRowCount < 0 ? Data.Count : _totalRowCount;
            }
            if (arguments.MaximumRows > 0)
            {
                if (UsingServerPaging)
                {
                    GuardTotalRowCountNotNegative(TotalRowCount);
                }
                else
                {
                    GuardStartRowIndexNotNegative(arguments);

                    if ((Data.Count == 0 && arguments.StartRowIndex > 0) || (Data.Count > 0 && (arguments.StartRowIndex >= Data.Count)))
                    {
                        throw new ArgumentOutOfRangeException(String.Format(CultureInfo.CurrentCulture, Resources.StartRowIndexOutOfRange, arguments.StartRowIndex, Data.Count));
                    }

                    int rowsLeft = Data.Count - arguments.StartRowIndex;
                    int rowCount = Math.Min(rowsLeft, arguments.MaximumRows);
                    return(Data.GetRange(arguments.StartRowIndex, rowCount));
                }
            }

            return(Data);
        }
 void TestableObjectContainerDataSource_Selecting(object sender, ObjectContainerDataSourceSelectingEventArgs e)
 {
     _SelectingFired = true;
 }
 // <snippet id="Selecting">
 protected void CustomersDataSource_Selecting(object sender, ObjectContainerDataSourceSelectingEventArgs e)
 {
     _presenter.OnSelecting(e.Arguments.StartRowIndex, e.Arguments.MaximumRows, e.Arguments.SortExpression);
 }