Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / UI / ListSourceHelper.cs / 1 / ListSourceHelper.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System.Collections; using System.ComponentModel; using System.Security.Permissions; [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public static class ListSourceHelper { public static bool ContainsListCollection(IDataSource dataSource) { ICollection viewNames = dataSource.GetViewNames(); if (viewNames != null && viewNames.Count > 0) { return true; } return false; } public static IList GetList(IDataSource dataSource) { ICollection viewNames = dataSource.GetViewNames(); if (viewNames != null && viewNames.Count > 0) { return new ListSourceList(dataSource); } return null; } internal sealed class ListSourceList : CollectionBase, ITypedList { IDataSource _dataSource; public ListSourceList(IDataSource dataSource) { _dataSource = dataSource; ((IList)this).Add(new ListSourceRow(_dataSource)); } #region ITypedList implementation string ITypedList.GetListName(PropertyDescriptor[] listAccessors) { return String.Empty; } PropertyDescriptorCollection ITypedList.GetItemProperties(PropertyDescriptor[] listAccessors) { if (_dataSource != null) { ICollection viewNames = _dataSource.GetViewNames(); if (viewNames != null && viewNames.Count > 0) { string[] viewNamesArray = new string[viewNames.Count]; viewNames.CopyTo(viewNamesArray, 0); PropertyDescriptor[] props = new PropertyDescriptor[viewNames.Count]; for (int i = 0; i < viewNamesArray.Length; i++) { props[i] = new ListSourcePropertyDescriptor(viewNamesArray[i]); } return new PropertyDescriptorCollection(props); } } return new PropertyDescriptorCollection(null); } #endregion ITypedList implementations } internal class ListSourceRow { IDataSource _dataSource; public ListSourceRow(IDataSource dataSource) { _dataSource = dataSource; } public IDataSource DataSource { get { return _dataSource; } } } internal class ListSourcePropertyDescriptor : PropertyDescriptor { string _name; public ListSourcePropertyDescriptor(string name) : base(name, null) { _name = name; } public override Type ComponentType { get { return typeof(ListSourceRow); } } public override bool IsReadOnly { get { return true; } } public override Type PropertyType { get { return typeof(IEnumerable); } } public override bool CanResetValue(object value) { return false; } public override object GetValue(object source) { if (source is ListSourceRow) { ListSourceRow row = (ListSourceRow)source; IDataSource dataSource = row.DataSource; return dataSource.GetView(_name).ExecuteSelect(DataSourceSelectArguments.Empty); } return null; } public override void ResetValue(object component) { throw new NotSupportedException(); } public override void SetValue(object component, object value) { throw new NotSupportedException(); } public override bool ShouldSerializeValue(object component) { return false; } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ProxyGenerationError.cs
- ScriptIgnoreAttribute.cs
- PropertyInformationCollection.cs
- ConnectionConsumerAttribute.cs
- DiscoveryDocumentLinksPattern.cs
- StoreItemCollection.cs
- StringFreezingAttribute.cs
- BmpBitmapEncoder.cs
- ScriptComponentDescriptor.cs
- RenderDataDrawingContext.cs
- COM2PictureConverter.cs
- HtmlPanelAdapter.cs
- PermissionSetTriple.cs
- EntityContainerEntitySet.cs
- SqlStatistics.cs
- HttpHeaderCollection.cs
- DataGridViewRow.cs
- XsltSettings.cs
- AuthorizationSection.cs
- Light.cs
- EmptyQuery.cs
- AnimationClock.cs
- XpsLiterals.cs
- WCFServiceClientProxyGenerator.cs
- CodeIndexerExpression.cs
- XPathNodeHelper.cs
- NativeMethods.cs
- BuilderPropertyEntry.cs
- TableProviderWrapper.cs
- PageContentAsyncResult.cs
- CodeObject.cs
- TextEditorSelection.cs
- ResolveResponseInfo.cs
- _NtlmClient.cs
- TransactionScope.cs
- SQLBinaryStorage.cs
- ObjectDataSourceView.cs
- Calendar.cs
- XmlCustomFormatter.cs
- ArgumentDesigner.xaml.cs
- ToolboxComponentsCreatedEventArgs.cs
- SafeSecurityHandles.cs
- Menu.cs
- TextElementCollection.cs
- Validator.cs
- _DisconnectOverlappedAsyncResult.cs
- CompilerResults.cs
- MatrixTransform3D.cs
- Version.cs
- HasRunnableWorkflowEvent.cs
- SafeNativeMethods.cs
- TimelineCollection.cs
- WebPartConnectionsConfigureVerb.cs
- HandleExceptionArgs.cs
- ConstNode.cs
- Path.cs
- SafeArrayTypeMismatchException.cs
- PinnedBufferMemoryStream.cs
- HttpWebResponse.cs
- XmlWriterSettings.cs
- SoapAttributeOverrides.cs
- ToolStripPanelSelectionBehavior.cs
- CacheDependency.cs
- DataObjectMethodAttribute.cs
- LayoutManager.cs
- UnmanagedBitmapWrapper.cs
- EnumerableWrapperWeakToStrong.cs
- CommandConverter.cs
- DataGridViewMethods.cs
- XmlSchemaInferenceException.cs
- ClientTargetCollection.cs
- PrintPreviewControl.cs
- EmbeddedMailObjectsCollection.cs
- ConsumerConnectionPointCollection.cs
- BigInt.cs
- ScrollContentPresenter.cs
- ClientApiGenerator.cs
- DataGridRow.cs
- HostProtectionException.cs
- XmlILOptimizerVisitor.cs
- XPathNodeIterator.cs
- DataGridTableCollection.cs
- RegexStringValidatorAttribute.cs
- DelayedRegex.cs
- SqlDataReader.cs
- ClientSettingsSection.cs
- ParserStreamGeometryContext.cs
- BatchStream.cs
- JoinTreeSlot.cs
- EntityStoreSchemaFilterEntry.cs
- WindowPattern.cs
- EntityDataSourceSelectingEventArgs.cs
- CssClassPropertyAttribute.cs
- KerberosSecurityTokenAuthenticator.cs
- DataGridViewColumnCollection.cs
- ThousandthOfEmRealDoubles.cs
- GB18030Encoding.cs
- SynchronizationLockException.cs
- PathTooLongException.cs
- HtmlInputImage.cs