Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / DynamicData / DynamicData / DynamicFilter.cs / 1305376 / DynamicFilter.cs
using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Web.Compilation; using System.Web.UI; using System.Web.UI.WebControls; #if !ORYX_VNEXT using System.Web.UI.WebControls.Expressions; using System.Web.Resources; #else using Microsoft.Web.Data.UI.WebControls.Expressions; using Microsoft.Web.Data.UI.WebControls; #endif namespace System.Web.DynamicData { public class DynamicFilter : Control, IFilterExpressionProvider { private HttpContextBase _context; private IQueryableDataSource _dataSource; private Func_filterLoader; private QueryableFilterUserControl _filterUserControl; protected internal MetaColumn Column { get; private set; } /// /// The name of the column that this control handles /// [ Category("Data"), DefaultValue(""), ResourceDescription("DynamicFilter_DataField") ] public string DataField { get { object o = ViewState["DataField"]; return (o == null) ? String.Empty : (string)o; } set { ViewState["DataField"] = value; } } ////// An optional property that can be used to override the column's default default filter UI hint. /// [ Category("Behavior"), DefaultValue(""), ResourceDescription("DynamicFilter_FilterUIHint") ] public string FilterUIHint { get { object o = ViewState["FilterUIHint"]; return (o == null) ? String.Empty : (string)o; } set { ViewState["FilterUIHint"] = value; } } public DynamicFilter() : this(CreateUserControl) { } // internal for unit testing internal DynamicFilter(FuncfilterLoader) { _filterLoader = filterLoader; } // internal for unit testing internal static QueryableFilterUserControl CreateUserControl(MetaColumn column, string filterUiHint) { return column.Model.FilterFactory.CreateFilterControl(column, filterUiHint); } internal new HttpContextBase Context { get { return _context ?? new HttpContextWrapper(HttpContext.Current); } set { _context = value; } } [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public event EventHandler FilterChanged; /// /// Returns the filter template that was created for this control. /// [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Control FilterTemplate { get { return _filterUserControl; } } protected override void Render(HtmlTextWriter writer) { if (DesignMode) { writer.Write("[" + GetType().Name + "]"); } else { base.Render(writer); } } private void EnsureInit(IQueryableDataSource dataSource) { if (_filterUserControl == null) { MetaTable table = DynamicDataExtensions.GetMetaTable(dataSource, Context); Column = table.GetColumn(DataField); _filterUserControl = _filterLoader(Column, FilterUIHint); _filterUserControl.Initialize(Column, dataSource, Context); _filterUserControl.FilterChanged += new EventHandler(Child_FilterChanged); Controls.Add(_filterUserControl); } } private void Child_FilterChanged(object sender, EventArgs e) { EventHandler eventHandler = FilterChanged; if (eventHandler != null) { eventHandler(sender, e); } } internal void Initialize(IQueryableDataSource dataSource) { Debug.Assert(dataSource != null); EnsureInit(dataSource); } #region IFilterExpressionProvider Members void IFilterExpressionProvider.Initialize(IQueryableDataSource dataSource) { if (dataSource == null) { throw new ArgumentNullException("dataSource"); } _dataSource = dataSource; Page.InitComplete += new EventHandler(Page_InitComplete); } void Page_InitComplete(object sender, EventArgs e) { Debug.Assert(_dataSource != null); EnsureInit(_dataSource); } IQueryable IFilterExpressionProvider.GetQueryable(IQueryable source) { return _filterUserControl.GetQueryable(source); } #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
- SqlDependencyUtils.cs
- TitleStyle.cs
- DataRecordInfo.cs
- QueryCacheKey.cs
- TransformerTypeCollection.cs
- MessageQueueAccessControlEntry.cs
- PageAsyncTask.cs
- DockPatternIdentifiers.cs
- SafeTokenHandle.cs
- XmlLanguageConverter.cs
- RadioButton.cs
- DatagridviewDisplayedBandsData.cs
- WebMessageFormatHelper.cs
- NotSupportedException.cs
- Vector3DCollection.cs
- HttpRawResponse.cs
- SQLByte.cs
- HttpInputStream.cs
- MemberInfoSerializationHolder.cs
- GridViewColumnHeaderAutomationPeer.cs
- BitmapEffectGroup.cs
- GifBitmapEncoder.cs
- CurrencyWrapper.cs
- TypeUsage.cs
- GroupQuery.cs
- BaseTemplateBuildProvider.cs
- Tokenizer.cs
- BrowserDefinitionCollection.cs
- HtmlTextArea.cs
- CompositionAdorner.cs
- PrintingPermission.cs
- BooleanToVisibilityConverter.cs
- LayoutEvent.cs
- FragmentNavigationEventArgs.cs
- SessionParameter.cs
- Clause.cs
- ClassValidator.cs
- DbSetClause.cs
- IgnoreFlushAndCloseStream.cs
- DataControlCommands.cs
- PartialCachingControl.cs
- CodeSnippetExpression.cs
- HashCodeCombiner.cs
- NGCSerializationManagerAsync.cs
- NativeWindow.cs
- WindowsProgressbar.cs
- InteropEnvironment.cs
- HtmlLink.cs
- ThreadAbortException.cs
- CompilerScope.Storage.cs
- VisualTransition.cs
- RepeatButtonAutomationPeer.cs
- LocationEnvironment.cs
- Material.cs
- AccessedThroughPropertyAttribute.cs
- PrimaryKeyTypeConverter.cs
- ProfilePropertyNameValidator.cs
- Assembly.cs
- PriorityQueue.cs
- FilterableAttribute.cs
- RadioButton.cs
- ModuleBuilder.cs
- TimelineCollection.cs
- TextParagraph.cs
- ExtensionQuery.cs
- IList.cs
- DataGridViewTopRowAccessibleObject.cs
- MetadataArtifactLoaderComposite.cs
- LiteralControl.cs
- GridViewRowEventArgs.cs
- EncodedStreamFactory.cs
- querybuilder.cs
- JournalEntryListConverter.cs
- SoapIncludeAttribute.cs
- SpeechRecognitionEngine.cs
- NotifyParentPropertyAttribute.cs
- UIElementPropertyUndoUnit.cs
- TaiwanCalendar.cs
- DataServiceRequestException.cs
- ExtentCqlBlock.cs
- Schema.cs
- SrgsGrammarCompiler.cs
- XmlSchemaRedefine.cs
- DependencyPropertyAttribute.cs
- _WinHttpWebProxyDataBuilder.cs
- SmiEventSink.cs
- ContentWrapperAttribute.cs
- VersionedStreamOwner.cs
- EntryPointNotFoundException.cs
- SafeRightsManagementSessionHandle.cs
- CompiledQuery.cs
- IItemProperties.cs
- SoapSchemaExporter.cs
- NgenServicingAttributes.cs
- ResourceAssociationSet.cs
- ImageUrlEditor.cs
- GridViewCancelEditEventArgs.cs
- CreateInstanceBinder.cs
- CommonDialog.cs
- XmlStreamStore.cs