Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / DataSourceHelper.cs / 1305376 / DataSourceHelper.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Data; using System.Diagnostics; namespace System.Web.UI.MobileControls { /* * Data Source Helper class. Copied fairly verbatim from ASP.NET code base, and modified * to match our coding standards and, more importantly, use our exceptions. * The ASP.NET file is /system/web/ui/DataSourceHelper.cs (a private class) * * Copyright (c) 2000 Microsoft Corporation */ [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] 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. // (Ignore DataMember parameter.) 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 ((dataMember == null) || (dataMember.Length == 0)) { 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 ArgumentException( SR.GetString(SR.DataSourceHelper_MissingDataMember, dataMember)); } else { throw new ArgumentException( SR.GetString(SR.DataSourceHelper_DataSourceWithoutDataMember, "List DataSource")); } } } 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. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.Data; using System.Diagnostics; namespace System.Web.UI.MobileControls { /* * Data Source Helper class. Copied fairly verbatim from ASP.NET code base, and modified * to match our coding standards and, more importantly, use our exceptions. * The ASP.NET file is /system/web/ui/DataSourceHelper.cs (a private class) * * Copyright (c) 2000 Microsoft Corporation */ [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] 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. // (Ignore DataMember parameter.) 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 ((dataMember == null) || (dataMember.Length == 0)) { 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 ArgumentException( SR.GetString(SR.DataSourceHelper_MissingDataMember, dataMember)); } else { throw new ArgumentException( SR.GetString(SR.DataSourceHelper_DataSourceWithoutDataMember, "List DataSource")); } } } if (dataSource is IEnumerable) { return (IEnumerable)dataSource; } return null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DecimalAnimationBase.cs
- XmlSerializerAssemblyAttribute.cs
- AppDomainShutdownMonitor.cs
- PieceNameHelper.cs
- StringKeyFrameCollection.cs
- MissingSatelliteAssemblyException.cs
- NavigationPropertyEmitter.cs
- CodeArrayCreateExpression.cs
- FrameworkElementAutomationPeer.cs
- ColumnPropertiesGroup.cs
- EncodingNLS.cs
- TypeConstant.cs
- TemplateManager.cs
- DataMemberListEditor.cs
- PropertyStore.cs
- NameNode.cs
- EmptyStringExpandableObjectConverter.cs
- FrameSecurityDescriptor.cs
- WinFormsSecurity.cs
- BuildManager.cs
- DataBoundControl.cs
- SortDescriptionCollection.cs
- _SslState.cs
- EventLogEntryCollection.cs
- GenericIdentity.cs
- CollectionBase.cs
- SystemIPGlobalStatistics.cs
- Command.cs
- Window.cs
- TraceRecord.cs
- RSAPKCS1KeyExchangeFormatter.cs
- JavaScriptSerializer.cs
- PhoneCall.cs
- SafeCoTaskMem.cs
- TypeRestriction.cs
- CommandConverter.cs
- Int32Storage.cs
- UserControlDocumentDesigner.cs
- RootBrowserWindow.cs
- SqlBuilder.cs
- AppDomainCompilerProxy.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- GifBitmapDecoder.cs
- PersonalizationProviderHelper.cs
- KeysConverter.cs
- UnknownWrapper.cs
- TextTreeUndoUnit.cs
- ToolStripContainer.cs
- DefaultAsyncDataDispatcher.cs
- ToolboxItemAttribute.cs
- EventSinkActivityDesigner.cs
- TypeConverterMarkupExtension.cs
- MsmqIntegrationBindingElement.cs
- ServiceNameElementCollection.cs
- Lease.cs
- DataContract.cs
- FixedPageProcessor.cs
- RoleService.cs
- DrawListViewColumnHeaderEventArgs.cs
- XmlReturnReader.cs
- XPathNode.cs
- ExpanderAutomationPeer.cs
- SqlNode.cs
- EntityDataSourceDesignerHelper.cs
- DataBinding.cs
- StreamMarshaler.cs
- RecordBuilder.cs
- DateTimeFormatInfo.cs
- IImplicitResourceProvider.cs
- Form.cs
- XAMLParseException.cs
- UnsafeNativeMethods.cs
- RoleProviderPrincipal.cs
- DrawToolTipEventArgs.cs
- StateMachine.cs
- RequestCachePolicyConverter.cs
- ImportContext.cs
- AlphabeticalEnumConverter.cs
- SafeLibraryHandle.cs
- UrlPath.cs
- AsyncContentLoadedEventArgs.cs
- QueuePropertyVariants.cs
- XmlDesignerDataSourceView.cs
- ConfigXmlElement.cs
- TableLayoutPanel.cs
- CollectionContainer.cs
- PartialCachingControl.cs
- VectorCollection.cs
- TreeNodeStyleCollection.cs
- StringStorage.cs
- Events.cs
- ListViewDeletedEventArgs.cs
- PointLight.cs
- SpellCheck.cs
- SizeLimitedCache.cs
- OrderPreservingSpoolingTask.cs
- IgnorePropertiesAttribute.cs
- XmlLangPropertyAttribute.cs
- KnownIds.cs
- BinaryWriter.cs