Code:
/ DotNET / DotNET / 8.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
- UnicodeEncoding.cs
- DataGridViewCellCancelEventArgs.cs
- SqlSupersetValidator.cs
- ToolBarPanel.cs
- FilterUserControlBase.cs
- XmlHierarchicalDataSourceView.cs
- CodeTypeMember.cs
- DependencyPropertyChangedEventArgs.cs
- FontDifferentiator.cs
- QuadTree.cs
- SystemWebCachingSectionGroup.cs
- EventMappingSettingsCollection.cs
- NetMsmqSecurityMode.cs
- TypeLoadException.cs
- TransportChannelFactory.cs
- KnownBoxes.cs
- _Rfc2616CacheValidators.cs
- UndoManager.cs
- ListControl.cs
- AuthenticationModuleElement.cs
- EpmSyndicationContentDeSerializer.cs
- IsolationInterop.cs
- HelpKeywordAttribute.cs
- RightsManagementEncryptionTransform.cs
- _FixedSizeReader.cs
- DecoderReplacementFallback.cs
- ColumnMapProcessor.cs
- GlobalAllocSafeHandle.cs
- MissingFieldException.cs
- WebHttpSecurityElement.cs
- ManagementObjectSearcher.cs
- BooleanExpr.cs
- Pen.cs
- DataService.cs
- MouseEvent.cs
- ManagedIStream.cs
- remotingproxy.cs
- ListViewUpdatedEventArgs.cs
- LogSwitch.cs
- ConfigXmlComment.cs
- VectorAnimationUsingKeyFrames.cs
- NullReferenceException.cs
- DelayedRegex.cs
- ManagementOperationWatcher.cs
- CustomErrorCollection.cs
- datacache.cs
- SchemaAttDef.cs
- KeyFrames.cs
- ZipIOCentralDirectoryFileHeader.cs
- EntityConnection.cs
- StorageEntityTypeMapping.cs
- BulletDecorator.cs
- ValidatingCollection.cs
- followingquery.cs
- NodeInfo.cs
- BinaryCommonClasses.cs
- EntityExpressionVisitor.cs
- ACL.cs
- CodeCatchClause.cs
- ControllableStoryboardAction.cs
- metadatamappinghashervisitor.hashsourcebuilder.cs
- SynchronizedDispatch.cs
- TypedTableGenerator.cs
- StrongNameMembershipCondition.cs
- TdsParserStateObject.cs
- BorderGapMaskConverter.cs
- GeometryGroup.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- ControlValuePropertyAttribute.cs
- MembershipValidatePasswordEventArgs.cs
- EpmContentDeSerializer.cs
- XamlToRtfParser.cs
- EditorZoneDesigner.cs
- EntitySet.cs
- ArgumentDirectionHelper.cs
- HttpValueCollection.cs
- WebDisplayNameAttribute.cs
- MdImport.cs
- Identity.cs
- ProviderUtil.cs
- SqlEnums.cs
- DataViewManager.cs
- ComponentChangedEvent.cs
- ObjectListCommand.cs
- String.cs
- UnsafeCollabNativeMethods.cs
- LightweightEntityWrapper.cs
- DbTransaction.cs
- TextElementEditingBehaviorAttribute.cs
- XamlTypeMapper.cs
- SqlParameter.cs
- XappLauncher.cs
- ImageAnimator.cs
- AppDomain.cs
- HealthMonitoringSectionHelper.cs
- IndexOutOfRangeException.cs
- WebPartHelpVerb.cs
- HttpCachePolicyElement.cs
- LogRecordSequence.cs
- DataSourceXmlTextReader.cs