Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / ListDataHelper.cs / 1305376 / ListDataHelper.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System.Collections; using System.Diagnostics; namespace System.Web.UI.MobileControls { /* * List Data Helper 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 ListDataHelper { private IListControl _parent; private StateBag _parentViewState; private MobileListItemCollection _items; private Object _dataSource; private IEnumerable _resolvedDataSource; private int _dataSourceCount = -1; private String _dataTextField; private String _dataValueField; private bool _bindFromFields; internal /*public*/ ListDataHelper(IListControl parent, StateBag parentViewState) { _parent = parent; _parentViewState = parentViewState; } internal /*public*/ MobileListItemCollection Items { get { if (_items == null) { _items = new MobileListItemCollection(); if (_parent.TrackingViewState) { ((IStateManager)_items).TrackViewState(); } } return _items; } } internal /*public*/ bool HasItems() { return _items != null; } internal /*public*/ Object DataSource { get { return _dataSource; } set { _dataSource = value; _resolvedDataSource = null; } } internal /*public*/ String DataMember { get { String s = (String)_parentViewState["DataMember"]; return s == null ? String.Empty : s; } set { _parentViewState["DataMember"] = value; } } internal /*public*/ String DataTextField { get { String s = (String)_parentViewState["DataTextField"]; return (s != null) ? s : String.Empty; } set { _parentViewState["DataTextField"] = value; } } internal /*public*/ String DataValueField { get { String s = (String)_parentViewState["DataValueField"]; return (s != null) ? s : String.Empty; } set { _parentViewState["DataValueField"] = value; } } internal /*public*/ IEnumerable ResolvedDataSource { get { if (_resolvedDataSource == null) { _resolvedDataSource = DataSourceHelper.GetResolvedDataSource(DataSource, DataMember); } return _resolvedDataSource; } } /* internal int DataSourceCount { get { if (_dataSourceCount == -1) { IEnumerable dataSource = ResolvedDataSource; if (dataSource != null) { ICollection collection = dataSource as ICollection; if (collection != null) { _dataSourceCount = collection.Count; } else { int count = 0; IEnumerator enumerator = dataSource.GetEnumerator(); while (enumerator.MoveNext()) { count++; } _dataSourceCount = count; } } else { _dataSourceCount = 0; } } return _dataSourceCount; } } */ internal /*public*/ void CreateItems(IEnumerable dataSource) { Debug.Assert (dataSource != null); Items.Clear(); _dataTextField = DataTextField; _dataValueField = DataValueField; _bindFromFields = (_dataTextField.Length > 0) || (_dataValueField.Length > 0); foreach (Object dataItem in dataSource) { MobileListItem listItem = CreateItem(dataItem); if (listItem != null) { AddItem(listItem); } } _dataSourceCount = Items.Count; } private MobileListItem CreateItem(Object dataItem) { MobileListItem listItem = null; String textField = null; String valueField = null; if (_bindFromFields) { if (_dataTextField.Length > 0) { textField = DataBinder.GetPropertyValue(dataItem, _dataTextField, "{0}"); } if (_dataValueField.Length > 0) { valueField = DataBinder.GetPropertyValue(dataItem, _dataValueField, "{0}"); } } else { textField = dataItem.ToString(); } listItem = new MobileListItem(dataItem, textField, valueField); // Use delegated data binding, if specified. if (dataItem != null) { _parent.OnItemDataBind(new ListDataBindEventArgs(listItem, dataItem)); } return listItem; } internal /*public*/ void AddItem(MobileListItem item) { MobileListItemCollection items = Items; items.Add(item); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System.Collections; using System.Diagnostics; namespace System.Web.UI.MobileControls { /* * List Data Helper 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 ListDataHelper { private IListControl _parent; private StateBag _parentViewState; private MobileListItemCollection _items; private Object _dataSource; private IEnumerable _resolvedDataSource; private int _dataSourceCount = -1; private String _dataTextField; private String _dataValueField; private bool _bindFromFields; internal /*public*/ ListDataHelper(IListControl parent, StateBag parentViewState) { _parent = parent; _parentViewState = parentViewState; } internal /*public*/ MobileListItemCollection Items { get { if (_items == null) { _items = new MobileListItemCollection(); if (_parent.TrackingViewState) { ((IStateManager)_items).TrackViewState(); } } return _items; } } internal /*public*/ bool HasItems() { return _items != null; } internal /*public*/ Object DataSource { get { return _dataSource; } set { _dataSource = value; _resolvedDataSource = null; } } internal /*public*/ String DataMember { get { String s = (String)_parentViewState["DataMember"]; return s == null ? String.Empty : s; } set { _parentViewState["DataMember"] = value; } } internal /*public*/ String DataTextField { get { String s = (String)_parentViewState["DataTextField"]; return (s != null) ? s : String.Empty; } set { _parentViewState["DataTextField"] = value; } } internal /*public*/ String DataValueField { get { String s = (String)_parentViewState["DataValueField"]; return (s != null) ? s : String.Empty; } set { _parentViewState["DataValueField"] = value; } } internal /*public*/ IEnumerable ResolvedDataSource { get { if (_resolvedDataSource == null) { _resolvedDataSource = DataSourceHelper.GetResolvedDataSource(DataSource, DataMember); } return _resolvedDataSource; } } /* internal int DataSourceCount { get { if (_dataSourceCount == -1) { IEnumerable dataSource = ResolvedDataSource; if (dataSource != null) { ICollection collection = dataSource as ICollection; if (collection != null) { _dataSourceCount = collection.Count; } else { int count = 0; IEnumerator enumerator = dataSource.GetEnumerator(); while (enumerator.MoveNext()) { count++; } _dataSourceCount = count; } } else { _dataSourceCount = 0; } } return _dataSourceCount; } } */ internal /*public*/ void CreateItems(IEnumerable dataSource) { Debug.Assert (dataSource != null); Items.Clear(); _dataTextField = DataTextField; _dataValueField = DataValueField; _bindFromFields = (_dataTextField.Length > 0) || (_dataValueField.Length > 0); foreach (Object dataItem in dataSource) { MobileListItem listItem = CreateItem(dataItem); if (listItem != null) { AddItem(listItem); } } _dataSourceCount = Items.Count; } private MobileListItem CreateItem(Object dataItem) { MobileListItem listItem = null; String textField = null; String valueField = null; if (_bindFromFields) { if (_dataTextField.Length > 0) { textField = DataBinder.GetPropertyValue(dataItem, _dataTextField, "{0}"); } if (_dataValueField.Length > 0) { valueField = DataBinder.GetPropertyValue(dataItem, _dataValueField, "{0}"); } } else { textField = dataItem.ToString(); } listItem = new MobileListItem(dataItem, textField, valueField); // Use delegated data binding, if specified. if (dataItem != null) { _parent.OnItemDataBind(new ListDataBindEventArgs(listItem, dataItem)); } return listItem; } internal /*public*/ void AddItem(MobileListItem item) { MobileListItemCollection items = Items; items.Add(item); } } } // 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
- SqlDataSourceSelectingEventArgs.cs
- DataComponentGenerator.cs
- OleDbParameterCollection.cs
- SrgsElementList.cs
- CodeGenerator.cs
- EntityDataSourceViewSchema.cs
- Menu.cs
- GenericEnumerator.cs
- NotFiniteNumberException.cs
- CompositeControl.cs
- Style.cs
- SubclassTypeValidatorAttribute.cs
- MethodCallConverter.cs
- XmlDocumentFragment.cs
- CheckBoxFlatAdapter.cs
- ModuleBuilderData.cs
- KoreanCalendar.cs
- NativeMethods.cs
- ConfigurationPermission.cs
- PixelFormats.cs
- _IPv4Address.cs
- TagPrefixAttribute.cs
- CompilerErrorCollection.cs
- TemplateColumn.cs
- WindowsFormsEditorServiceHelper.cs
- EntityCollection.cs
- SystemColorTracker.cs
- _SslStream.cs
- BulletedListEventArgs.cs
- SemanticKeyElement.cs
- CodeTypeDeclaration.cs
- PermissionListSet.cs
- GestureRecognizer.cs
- TextServicesDisplayAttribute.cs
- UIElementPropertyUndoUnit.cs
- SetIterators.cs
- UserUseLicenseDictionaryLoader.cs
- InputBuffer.cs
- HttpCapabilitiesBase.cs
- SafePEFileHandle.cs
- DelegatingHeader.cs
- GestureRecognitionResult.cs
- MetadataCacheItem.cs
- DataServices.cs
- ZeroOpNode.cs
- DependencyPropertyKind.cs
- BitmapImage.cs
- StringUtil.cs
- BufferedGraphicsManager.cs
- SafeNativeMethodsMilCoreApi.cs
- DataGridViewRowEventArgs.cs
- FormViewPagerRow.cs
- CompilerGeneratedAttribute.cs
- XamlPoint3DCollectionSerializer.cs
- RunWorkerCompletedEventArgs.cs
- TraceHandlerErrorFormatter.cs
- sqlinternaltransaction.cs
- ImpersonateTokenRef.cs
- DetectRunnableInstancesTask.cs
- DataServiceConfiguration.cs
- SiteMapNode.cs
- StringComparer.cs
- ContextMarshalException.cs
- SignatureToken.cs
- MouseDevice.cs
- HitTestWithPointDrawingContextWalker.cs
- AppDomainAttributes.cs
- XamlBrushSerializer.cs
- MgmtConfigurationRecord.cs
- MasterPageCodeDomTreeGenerator.cs
- StreamGeometry.cs
- TransformerTypeCollection.cs
- DesignerAdRotatorAdapter.cs
- RequestBringIntoViewEventArgs.cs
- ObjectViewEntityCollectionData.cs
- FixedSOMTable.cs
- ApplicationServicesHostFactory.cs
- ButtonAutomationPeer.cs
- ConditionChanges.cs
- ExtendedProperty.cs
- Message.cs
- IteratorDescriptor.cs
- HtmlElementCollection.cs
- TextFormatter.cs
- SimpleTableProvider.cs
- DragEvent.cs
- GridViewCommandEventArgs.cs
- TableLayoutRowStyleCollection.cs
- CompModSwitches.cs
- EventBuilder.cs
- _CookieModule.cs
- ComPlusTypeLoader.cs
- Pair.cs
- DeobfuscatingStream.cs
- Configuration.cs
- ModifiableIteratorCollection.cs
- QilBinary.cs
- ToolboxItemAttribute.cs
- TrustLevel.cs
- Soap11ServerProtocol.cs