Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / WebControls / QueryableDataSource.cs / 1305376 / QueryableDataSource.cs
#if ORYX_VNEXT namespace Microsoft.Web.Data.UI.WebControls { #else namespace System.Web.UI.WebControls { #endif using System; using System.Collections; using System.Collections.ObjectModel; using System.ComponentModel; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Resources; using System.Diagnostics.CodeAnalysis; using System.Globalization; #if ORYX_VNEXT using Microsoft.Web.Data.UI.WebControls.Expressions; using System.Web; #else using System.Web.UI.WebControls.Expressions; #endif [ ParseChildren(true), PersistChildren(false) ] public abstract class QueryableDataSource : DataSourceControl, IQueryableDataSource { private const string DefaultViewName = "DefaultView"; private ReadOnlyCollection_viewNames; private QueryableDataSourceView _view; #if !ORYX_VNEXT private readonly new IPage _page; #else private readonly IPage _page; #endif internal QueryableDataSource(IPage page) { _page = page; } internal QueryableDataSource(QueryableDataSourceView view) { _view = view; } protected QueryableDataSource() { } [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification="View is used by derived types")] private QueryableDataSourceView View { get { if (_view == null) { _view = CreateQueryableView(); } return _view; } } internal IPage IPage { get { if (_page != null) { return _page; } else { Page page = Page; if (page == null) { throw new InvalidOperationException(AtlasWeb.Common_PageCannotBeNull); } return new PageWrapper(page); } } } protected abstract QueryableDataSourceView CreateQueryableView(); protected override ICollection GetViewNames() { if (_viewNames == null) { _viewNames = new ReadOnlyCollection (new[] { DefaultViewName }); } return _viewNames; } protected override DataSourceView GetView(string viewName) { if (viewName == null) { throw new ArgumentNullException("viewName"); } // viewName comes from the DataMember property on the databound control and is an empty string // by default. An empty string should be treated as if it were the default view name. if ((viewName.Length != 0) && !String.Equals(viewName, DefaultViewName, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.LinqDataSource_InvalidViewName, ID, DefaultViewName), "viewName"); } return View; } [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers", MessageId = "0#")] #if ORYX_VNEXT protected override void OnInit(EventArgs e) { #else protected internal override void OnInit(EventArgs e) { #endif base.OnInit(e); IPage.LoadComplete += new EventHandler(OnPageLoadComplete); } // Used for unit testing only internal void SetView(QueryableDataSourceView view) { _view = view; } protected virtual void UpdateParameterVales() { View.WhereParameters.UpdateValues(Context, this); View.OrderGroupsByParameters.UpdateValues(Context, this); View.GroupByParameters.UpdateValues(Context, this); View.OrderByParameters.UpdateValues(Context, this); View.SelectNewParameters.UpdateValues(Context, this); } private void OnPageLoadComplete(object sender, EventArgs e) { UpdateParameterVales(); } protected override object SaveViewState() { Pair myState = new Pair(); myState.First = base.SaveViewState(); if (_view != null) { myState.Second = ((IStateManager)_view).SaveViewState(); } if ((myState.First == null) && (myState.Second == null)) { return null; } return myState; } protected override void TrackViewState() { base.TrackViewState(); if (_view != null) { ((IStateManager)_view).TrackViewState(); } } protected override void LoadViewState(object savedState) { if (savedState == null) { base.LoadViewState(null); } else { Pair myState = (Pair)savedState; base.LoadViewState(myState.First); if (myState.Second != null) { ((IStateManager)View).LoadViewState(myState.Second); } } } #region IQueryableDataSource Members public void RaiseViewChanged() { View.RaiseViewChanged(); } public event EventHandler QueryCreated { add { View.QueryCreated += value; } remove { View.QueryCreated -= value; } } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. #if ORYX_VNEXT namespace Microsoft.Web.Data.UI.WebControls { #else namespace System.Web.UI.WebControls { #endif using System; using System.Collections; using System.Collections.ObjectModel; using System.ComponentModel; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Resources; using System.Diagnostics.CodeAnalysis; using System.Globalization; #if ORYX_VNEXT using Microsoft.Web.Data.UI.WebControls.Expressions; using System.Web; #else using System.Web.UI.WebControls.Expressions; #endif [ ParseChildren(true), PersistChildren(false) ] public abstract class QueryableDataSource : DataSourceControl, IQueryableDataSource { private const string DefaultViewName = "DefaultView"; private ReadOnlyCollection _viewNames; private QueryableDataSourceView _view; #if !ORYX_VNEXT private readonly new IPage _page; #else private readonly IPage _page; #endif internal QueryableDataSource(IPage page) { _page = page; } internal QueryableDataSource(QueryableDataSourceView view) { _view = view; } protected QueryableDataSource() { } [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification="View is used by derived types")] private QueryableDataSourceView View { get { if (_view == null) { _view = CreateQueryableView(); } return _view; } } internal IPage IPage { get { if (_page != null) { return _page; } else { Page page = Page; if (page == null) { throw new InvalidOperationException(AtlasWeb.Common_PageCannotBeNull); } return new PageWrapper(page); } } } protected abstract QueryableDataSourceView CreateQueryableView(); protected override ICollection GetViewNames() { if (_viewNames == null) { _viewNames = new ReadOnlyCollection (new[] { DefaultViewName }); } return _viewNames; } protected override DataSourceView GetView(string viewName) { if (viewName == null) { throw new ArgumentNullException("viewName"); } // viewName comes from the DataMember property on the databound control and is an empty string // by default. An empty string should be treated as if it were the default view name. if ((viewName.Length != 0) && !String.Equals(viewName, DefaultViewName, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.LinqDataSource_InvalidViewName, ID, DefaultViewName), "viewName"); } return View; } [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers", MessageId = "0#")] #if ORYX_VNEXT protected override void OnInit(EventArgs e) { #else protected internal override void OnInit(EventArgs e) { #endif base.OnInit(e); IPage.LoadComplete += new EventHandler(OnPageLoadComplete); } // Used for unit testing only internal void SetView(QueryableDataSourceView view) { _view = view; } protected virtual void UpdateParameterVales() { View.WhereParameters.UpdateValues(Context, this); View.OrderGroupsByParameters.UpdateValues(Context, this); View.GroupByParameters.UpdateValues(Context, this); View.OrderByParameters.UpdateValues(Context, this); View.SelectNewParameters.UpdateValues(Context, this); } private void OnPageLoadComplete(object sender, EventArgs e) { UpdateParameterVales(); } protected override object SaveViewState() { Pair myState = new Pair(); myState.First = base.SaveViewState(); if (_view != null) { myState.Second = ((IStateManager)_view).SaveViewState(); } if ((myState.First == null) && (myState.Second == null)) { return null; } return myState; } protected override void TrackViewState() { base.TrackViewState(); if (_view != null) { ((IStateManager)_view).TrackViewState(); } } protected override void LoadViewState(object savedState) { if (savedState == null) { base.LoadViewState(null); } else { Pair myState = (Pair)savedState; base.LoadViewState(myState.First); if (myState.Second != null) { ((IStateManager)View).LoadViewState(myState.Second); } } } #region IQueryableDataSource Members public void RaiseViewChanged() { View.RaiseViewChanged(); } public event EventHandler QueryCreated { add { View.QueryCreated += value; } remove { View.QueryCreated -= value; } } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GZipDecoder.cs
- Domain.cs
- ToolStripDropDownClosingEventArgs.cs
- ObjectContextServiceProvider.cs
- EntityDesignerBuildProvider.cs
- XmlNodeReader.cs
- RequestQueryParser.cs
- ContentValidator.cs
- ContainsRowNumberChecker.cs
- MatrixAnimationUsingKeyFrames.cs
- HttpCachePolicy.cs
- FixedSOMLineRanges.cs
- KeyPullup.cs
- ClassHandlersStore.cs
- ObservableCollection.cs
- AssemblySettingAttributes.cs
- COM2PropertyBuilderUITypeEditor.cs
- ArraySortHelper.cs
- CustomActivityDesigner.cs
- SpecularMaterial.cs
- Unit.cs
- Attributes.cs
- _ShellExpression.cs
- ImageConverter.cs
- TypeBuilderInstantiation.cs
- FixedSOMTableRow.cs
- XPathSelfQuery.cs
- SizeAnimationUsingKeyFrames.cs
- SQLUtility.cs
- WorkflowService.cs
- filewebrequest.cs
- FixedPosition.cs
- CheckPair.cs
- xmlsaver.cs
- ReachDocumentSequenceSerializer.cs
- SelectionProcessor.cs
- MultipleViewProviderWrapper.cs
- PropertyGridDesigner.cs
- NullableDoubleAverageAggregationOperator.cs
- XPathPatternParser.cs
- SimplePropertyEntry.cs
- DockAndAnchorLayout.cs
- WindowsSlider.cs
- SafeEventLogWriteHandle.cs
- ObjectManager.cs
- SamlAuthorizationDecisionClaimResource.cs
- MyContact.cs
- URLString.cs
- BaseConfigurationRecord.cs
- GPPOINTF.cs
- MatcherBuilder.cs
- PasswordDeriveBytes.cs
- EndpointAddress10.cs
- ContextBase.cs
- XamlPointCollectionSerializer.cs
- BamlTreeMap.cs
- ToolStripDropDownClosingEventArgs.cs
- BindableAttribute.cs
- CodeAttributeDeclarationCollection.cs
- Adorner.cs
- IisTraceListener.cs
- DeviceSpecificDesigner.cs
- Hex.cs
- ComponentManagerBroker.cs
- QuaternionConverter.cs
- DataGridViewSelectedColumnCollection.cs
- PointUtil.cs
- MachineKeyConverter.cs
- RowSpanVector.cs
- AsyncPostBackErrorEventArgs.cs
- SizeLimitedCache.cs
- VirtualizingPanel.cs
- Types.cs
- PointLight.cs
- BulletDecorator.cs
- DrawingGroup.cs
- CommonXSendMessage.cs
- PauseStoryboard.cs
- LedgerEntry.cs
- AssemblyHash.cs
- BitmapFrameEncode.cs
- ArrayList.cs
- DefaultObjectMappingItemCollection.cs
- CaseInsensitiveOrdinalStringComparer.cs
- XmlLoader.cs
- CodeDomLoader.cs
- EllipticalNodeOperations.cs
- AffineTransform3D.cs
- GroupDescription.cs
- TagMapCollection.cs
- XmlHierarchyData.cs
- SHA384Managed.cs
- WSDualHttpSecurityElement.cs
- TimelineGroup.cs
- ImageList.cs
- OperationResponse.cs
- AspNetHostingPermission.cs
- hebrewshape.cs
- IriParsingElement.cs
- XsltArgumentList.cs