Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / DataSourceHelper.cs / 1 / DataSourceHelper.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Data; internal sealed class DataSourceHelper { private DataSourceHelper() { } internal static IEnumerable GetResolvedDataSource(object dataSource, string dataMember) { if (dataSource == null) return null; IListSource listSource = dataSource as IListSource; if (listSource != null) { IList memberList = listSource.GetList(); if (listSource.ContainsListCollection == false) { // the returned list is itself the list we need to bind to // return (IEnumerable)memberList; } if ((memberList != null) && (memberList is ITypedList)) { ITypedList typedMemberList = (ITypedList)memberList; PropertyDescriptorCollection propDescs = typedMemberList.GetItemProperties(new PropertyDescriptor[0]); if ((propDescs != null) && (propDescs.Count != 0)) { PropertyDescriptor listProperty = null; if (String.IsNullOrEmpty(dataMember)) { listProperty = propDescs[0]; } else { listProperty = propDescs.Find(dataMember, true); } if (listProperty != null) { object listRow = memberList[0]; object list = listProperty.GetValue(listRow); if ((list != null) && (list is IEnumerable)) { return (IEnumerable)list; } } throw new HttpException(SR.GetString(SR.ListSource_Missing_DataMember, dataMember)); } else { throw new HttpException(SR.GetString(SR.ListSource_Without_DataMembers)); } } } if (dataSource is IEnumerable) { return (IEnumerable)dataSource; } return null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Data; internal sealed class DataSourceHelper { private DataSourceHelper() { } internal static IEnumerable GetResolvedDataSource(object dataSource, string dataMember) { if (dataSource == null) return null; IListSource listSource = dataSource as IListSource; if (listSource != null) { IList memberList = listSource.GetList(); if (listSource.ContainsListCollection == false) { // the returned list is itself the list we need to bind to // return (IEnumerable)memberList; } if ((memberList != null) && (memberList is ITypedList)) { ITypedList typedMemberList = (ITypedList)memberList; PropertyDescriptorCollection propDescs = typedMemberList.GetItemProperties(new PropertyDescriptor[0]); if ((propDescs != null) && (propDescs.Count != 0)) { PropertyDescriptor listProperty = null; if (String.IsNullOrEmpty(dataMember)) { listProperty = propDescs[0]; } else { listProperty = propDescs.Find(dataMember, true); } if (listProperty != null) { object listRow = memberList[0]; object list = listProperty.GetValue(listRow); if ((list != null) && (list is IEnumerable)) { return (IEnumerable)list; } } throw new HttpException(SR.GetString(SR.ListSource_Missing_DataMember, dataMember)); } else { throw new HttpException(SR.GetString(SR.ListSource_Without_DataMembers)); } } } if (dataSource is IEnumerable) { return (IEnumerable)dataSource; } return null; } } } // 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
- PolyBezierSegmentFigureLogic.cs
- securitycriticaldata.cs
- DocumentSequence.cs
- AffineTransform3D.cs
- Errors.cs
- WebPageTraceListener.cs
- CompiledQuery.cs
- PolygonHotSpot.cs
- TextRangeEdit.cs
- LocatorGroup.cs
- ResXResourceWriter.cs
- SimpleType.cs
- ObjectIDGenerator.cs
- TextViewBase.cs
- TriggerAction.cs
- SettingsContext.cs
- SpecialNameAttribute.cs
- WCFServiceClientProxyGenerator.cs
- ExeContext.cs
- XmlMapping.cs
- XNodeNavigator.cs
- PKCS1MaskGenerationMethod.cs
- DataGridColumnCollection.cs
- DataSourceControl.cs
- Events.cs
- FileRecordSequence.cs
- OrCondition.cs
- SizeKeyFrameCollection.cs
- ILGenerator.cs
- PlacementWorkspace.cs
- TypeValidationEventArgs.cs
- CompiledAction.cs
- TaskFileService.cs
- AnimationClock.cs
- EdmConstants.cs
- Descriptor.cs
- TdsParserHelperClasses.cs
- COM2Enum.cs
- Comparer.cs
- DragStartedEventArgs.cs
- CreateBookmarkScope.cs
- PreservationFileWriter.cs
- Adorner.cs
- XmlSchemaImport.cs
- ServiceOperationWrapper.cs
- WindowsFormsHost.cs
- ConfigurationPropertyAttribute.cs
- Vector.cs
- ScalarType.cs
- dtdvalidator.cs
- ObjectSpanRewriter.cs
- LayoutTable.cs
- HighlightOverlayGlyph.cs
- URIFormatException.cs
- EventProvider.cs
- AdapterUtil.cs
- AddressAlreadyInUseException.cs
- XmlWrappingReader.cs
- StrokeRenderer.cs
- TrackingStringDictionary.cs
- HiddenFieldDesigner.cs
- WebBrowserBase.cs
- ConfigurationLocation.cs
- WinFormsComponentEditor.cs
- CacheMode.cs
- WorkflowLayouts.cs
- SpeechAudioFormatInfo.cs
- AmbientLight.cs
- DetailsViewInsertedEventArgs.cs
- HttpDictionary.cs
- WSIdentityFaultException.cs
- BuildResult.cs
- HashAlgorithm.cs
- DataTableMapping.cs
- EventWaitHandle.cs
- TreeViewItem.cs
- DeferredReference.cs
- TraceProvider.cs
- MSAAWinEventWrap.cs
- CommonDialog.cs
- ControlUtil.cs
- Configuration.cs
- ItemList.cs
- UserNameSecurityTokenParameters.cs
- Hyperlink.cs
- Label.cs
- ColorAnimationUsingKeyFrames.cs
- SqlParameterCollection.cs
- formatstringdialog.cs
- Automation.cs
- VoiceSynthesis.cs
- DataBoundControlAdapter.cs
- Memoizer.cs
- SiteMapProvider.cs
- RSAPKCS1SignatureFormatter.cs
- NestedContainer.cs
- GridViewRow.cs
- SafeSecurityHandles.cs
- ExceptionHelpers.cs
- WorkflowTransactionService.cs