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
- EdgeModeValidation.cs
- ApplicationSettingsBase.cs
- CodeCommentStatement.cs
- Form.cs
- BaseAsyncResult.cs
- MergeLocalizationDirectives.cs
- FrameworkElement.cs
- X509Extension.cs
- Triangle.cs
- HtmlElement.cs
- DetailsViewModeEventArgs.cs
- ConnectionStringSettings.cs
- DataKeyCollection.cs
- VersionedStream.cs
- OdbcException.cs
- ClientConfigPaths.cs
- Msmq4SubqueuePoisonHandler.cs
- TableSectionStyle.cs
- ZipPackagePart.cs
- CharacterMetricsDictionary.cs
- SqlGatherProducedAliases.cs
- ObjectItemNoOpAssemblyLoader.cs
- DataGridCaption.cs
- ValueType.cs
- DataRowCollection.cs
- ChannelServices.cs
- NCryptSafeHandles.cs
- CacheOutputQuery.cs
- XmlSchemaComplexType.cs
- BamlWriter.cs
- CodeEntryPointMethod.cs
- ArrayTypeMismatchException.cs
- RelatedView.cs
- SocketElement.cs
- Calendar.cs
- KeyTime.cs
- FontCacheUtil.cs
- ColorConverter.cs
- TempFiles.cs
- GridItemCollection.cs
- XmlSchemaException.cs
- MsmqDecodeHelper.cs
- XPathNavigator.cs
- DbConnectionPool.cs
- SchemaConstraints.cs
- CallbackValidator.cs
- AttachedProperty.cs
- DateTimeStorage.cs
- FusionWrap.cs
- PrintDocument.cs
- CursorConverter.cs
- ServicePointManagerElement.cs
- SectionUpdates.cs
- WebPartConnectionsCancelVerb.cs
- MDIControlStrip.cs
- XmlNamespaceMappingCollection.cs
- WebPartChrome.cs
- AuthorizationContext.cs
- TraceContext.cs
- TrackingMemoryStreamFactory.cs
- ScriptRegistrationManager.cs
- IInstanceTable.cs
- arabicshape.cs
- __ConsoleStream.cs
- XmlException.cs
- MissingMemberException.cs
- XPathNodeHelper.cs
- InvokeBinder.cs
- SqlClientWrapperSmiStream.cs
- Wizard.cs
- TextFormatter.cs
- SoapFormatter.cs
- OdbcConnection.cs
- AnimatedTypeHelpers.cs
- Baml6ConstructorInfo.cs
- EntityContainerAssociationSet.cs
- CalculatedColumn.cs
- LinkedList.cs
- GroupItem.cs
- EdmSchemaError.cs
- PtsHost.cs
- TreeView.cs
- Delegate.cs
- Grid.cs
- MetadataPropertyvalue.cs
- HttpModulesSection.cs
- ConsoleEntryPoint.cs
- DeploymentSectionCache.cs
- wmiprovider.cs
- XmlArrayAttribute.cs
- TableDetailsCollection.cs
- PackageRelationshipCollection.cs
- BaseParagraph.cs
- XmlCharType.cs
- GroupLabel.cs
- ThicknessAnimation.cs
- ScaleTransform3D.cs
- AsymmetricKeyExchangeDeformatter.cs
- BitmapSizeOptions.cs
- ConnectionProviderAttribute.cs