Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / UI / WebControls / QueryExtender.cs / 1305376 / QueryExtender.cs
#if ORYX_VNEXT namespace Microsoft.Web.Data.UI.WebControls { using System.Web; using Microsoft.Web.Data.UI.WebControls.Expressions; #else namespace System.Web.UI.WebControls { using System.Web.UI.WebControls.Expressions; #endif using System; using System.ComponentModel; using System.Drawing; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Security.Permissions; using System.Web.UI; using System.Web.Resources; [TargetControlType(typeof(IQueryableDataSource))] [NonVisualControl()] [DefaultProperty("TargetControlID")] #if !ORYX_VNEXT [ToolboxBitmap(typeof(QueryExtender), "QueryExtender.bmp")] [Designer("System.Web.UI.Design.QueryExtenderDesigner, " + AssemblyRef.SystemWebExtensionsDesign)] #endif [ParseChildren(true, "Expressions")] [PersistChildren(false)] public class QueryExtender : Control { private QueryExpression _query; private string _targetControlID; private IQueryableDataSource _dataSource; public QueryExtender() { } internal QueryExtender(IQueryableDataSource dataSource) { _dataSource = dataSource; } [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public virtual IQueryableDataSource DataSource { get { if (_dataSource == null) { if (String.IsNullOrEmpty(TargetControlID)) { throw new InvalidOperationException(AtlasWeb.DataSourceControlExtender_TargetControlIDMustBeSpecified); } #if ORYX_VNEXT _dataSource = DataSourceExtensions.FindControl(this, TargetControlID) as IQueryableDataSource; #else _dataSource = DataBoundControlHelper.FindControl(this, TargetControlID) as IQueryableDataSource; #endif // if (_dataSource == null) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, AtlasWeb.QueryExtender_DataSourceMustBeIQueryableDataSource, TargetControlID)); } } return _dataSource; } } [ Category("Behavior"), ResourceDescription("QueryExtender_Expressions"), PersistenceMode(PersistenceMode.InnerDefaultProperty), ] public DataSourceExpressionCollection Expressions { get { return Query.Expressions; } } [ Category("Behavior"), DefaultValue(""), IDReferenceProperty, ResourceDescription("ExtenderControl_TargetControlID"), SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID"), ] public virtual string TargetControlID { get { return _targetControlID ?? String.Empty; } set { if (_targetControlID != value) { _dataSource = null; _targetControlID = value; } } } private QueryExpression Query { get { if (_query == null) { _query = new QueryExpression(); } return _query; } } [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 if (!DesignMode) { DataSource.QueryCreated += new EventHandler(OnDataSourceQueryCreated); // Initialize the Query Query.Initialize(this, Context, DataSource); } base.OnInit(e); } private void OnDataSourceQueryCreated(object sender, QueryCreatedEventArgs e) { e.Query = Query.GetQueryable(e.Query); } protected override object SaveViewState() { Pair p = new Pair(); p.First = base.SaveViewState(); p.Second = _query != null ? ((IStateManager)_query.Expressions).SaveViewState() : null; return p; } protected override void LoadViewState(object savedState) { Pair p = (Pair)savedState; base.LoadViewState(p.First); if (p.Second != null) { ((IStateManager)Query.Expressions).LoadViewState(p.Second); } } protected override void TrackViewState() { base.TrackViewState(); if (_query != null) { ((IStateManager)_query.Expressions).TrackViewState(); } } } } // 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 { using System.Web; using Microsoft.Web.Data.UI.WebControls.Expressions; #else namespace System.Web.UI.WebControls { using System.Web.UI.WebControls.Expressions; #endif using System; using System.ComponentModel; using System.Drawing; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Security.Permissions; using System.Web.UI; using System.Web.Resources; [TargetControlType(typeof(IQueryableDataSource))] [NonVisualControl()] [DefaultProperty("TargetControlID")] #if !ORYX_VNEXT [ToolboxBitmap(typeof(QueryExtender), "QueryExtender.bmp")] [Designer("System.Web.UI.Design.QueryExtenderDesigner, " + AssemblyRef.SystemWebExtensionsDesign)] #endif [ParseChildren(true, "Expressions")] [PersistChildren(false)] public class QueryExtender : Control { private QueryExpression _query; private string _targetControlID; private IQueryableDataSource _dataSource; public QueryExtender() { } internal QueryExtender(IQueryableDataSource dataSource) { _dataSource = dataSource; } [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public virtual IQueryableDataSource DataSource { get { if (_dataSource == null) { if (String.IsNullOrEmpty(TargetControlID)) { throw new InvalidOperationException(AtlasWeb.DataSourceControlExtender_TargetControlIDMustBeSpecified); } #if ORYX_VNEXT _dataSource = DataSourceExtensions.FindControl(this, TargetControlID) as IQueryableDataSource; #else _dataSource = DataBoundControlHelper.FindControl(this, TargetControlID) as IQueryableDataSource; #endif // if (_dataSource == null) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, AtlasWeb.QueryExtender_DataSourceMustBeIQueryableDataSource, TargetControlID)); } } return _dataSource; } } [ Category("Behavior"), ResourceDescription("QueryExtender_Expressions"), PersistenceMode(PersistenceMode.InnerDefaultProperty), ] public DataSourceExpressionCollection Expressions { get { return Query.Expressions; } } [ Category("Behavior"), DefaultValue(""), IDReferenceProperty, ResourceDescription("ExtenderControl_TargetControlID"), SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID"), ] public virtual string TargetControlID { get { return _targetControlID ?? String.Empty; } set { if (_targetControlID != value) { _dataSource = null; _targetControlID = value; } } } private QueryExpression Query { get { if (_query == null) { _query = new QueryExpression(); } return _query; } } [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 if (!DesignMode) { DataSource.QueryCreated += new EventHandler (OnDataSourceQueryCreated); // Initialize the Query Query.Initialize(this, Context, DataSource); } base.OnInit(e); } private void OnDataSourceQueryCreated(object sender, QueryCreatedEventArgs e) { e.Query = Query.GetQueryable(e.Query); } protected override object SaveViewState() { Pair p = new Pair(); p.First = base.SaveViewState(); p.Second = _query != null ? ((IStateManager)_query.Expressions).SaveViewState() : null; return p; } protected override void LoadViewState(object savedState) { Pair p = (Pair)savedState; base.LoadViewState(p.First); if (p.Second != null) { ((IStateManager)Query.Expressions).LoadViewState(p.Second); } } protected override void TrackViewState() { base.TrackViewState(); if (_query != null) { ((IStateManager)_query.Expressions).TrackViewState(); } } } } // 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
- DataGridViewSelectedColumnCollection.cs
- Attributes.cs
- OdbcConnectionOpen.cs
- ToolstripProfessionalRenderer.cs
- CodeIdentifier.cs
- DetailsViewDeleteEventArgs.cs
- CompositeFontInfo.cs
- SQLDoubleStorage.cs
- XmlSchemaSimpleContent.cs
- QueryOptionExpression.cs
- TreeNodeMouseHoverEvent.cs
- BitmapEffect.cs
- SHA512Cng.cs
- EdmMember.cs
- MenuScrollingVisibilityConverter.cs
- Point.cs
- FontStretches.cs
- ViewManager.cs
- PropertyCondition.cs
- documentsequencetextview.cs
- EntitySet.cs
- DataGridViewRowPostPaintEventArgs.cs
- ValidateNames.cs
- GACIdentityPermission.cs
- COSERVERINFO.cs
- SynchronizationValidator.cs
- BCryptHashAlgorithm.cs
- BitmapEffectDrawingContextState.cs
- MessageBuffer.cs
- TextEndOfSegment.cs
- WebBrowsableAttribute.cs
- PageHandlerFactory.cs
- XmlException.cs
- RegisteredExpandoAttribute.cs
- ImageCodecInfoPrivate.cs
- CodeTypeDeclarationCollection.cs
- XmlSerializer.cs
- SelectionHighlightInfo.cs
- ImageAttributes.cs
- DataControlField.cs
- COM2EnumConverter.cs
- Models.cs
- Rotation3DAnimationBase.cs
- CodeTryCatchFinallyStatement.cs
- ScrollBar.cs
- Point.cs
- ParameterCollection.cs
- BasicKeyConstraint.cs
- DirectionalLight.cs
- QuotedPairReader.cs
- IssuedTokenClientBehaviorsElement.cs
- ListViewCancelEventArgs.cs
- ImageListUtils.cs
- WebBrowserBase.cs
- CryptoApi.cs
- CookieParameter.cs
- ConfigurationErrorsException.cs
- PartitionedStreamMerger.cs
- GetWinFXPath.cs
- QueryStringParameter.cs
- Ray3DHitTestResult.cs
- OneOfTypeConst.cs
- NTAccount.cs
- BypassElementCollection.cs
- OleCmdHelper.cs
- ResourceAssociationTypeEnd.cs
- TextTreeRootNode.cs
- EditingCommands.cs
- ObsoleteAttribute.cs
- DataGridViewCellLinkedList.cs
- ChangeDirector.cs
- CompiledRegexRunner.cs
- VarRemapper.cs
- DataGridViewCellConverter.cs
- DataGridViewSelectedColumnCollection.cs
- HttpApplicationFactory.cs
- Control.cs
- PhysicalAddress.cs
- UpdatePanel.cs
- MetafileHeaderEmf.cs
- Symbol.cs
- Stack.cs
- FormViewPagerRow.cs
- SystemSounds.cs
- WindowsListViewGroup.cs
- AstTree.cs
- TextDecorations.cs
- CodeFieldReferenceExpression.cs
- TextSelectionHighlightLayer.cs
- CredentialCache.cs
- Repeater.cs
- ConnectionConsumerAttribute.cs
- Label.cs
- DockProviderWrapper.cs
- SerializationBinder.cs
- TemplateContainer.cs
- CurrentChangingEventArgs.cs
- AsyncResult.cs
- ConfigPathUtility.cs
- LinqDataSourceContextEventArgs.cs