Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / xsp / System / Web / UI / WebParts / WebPartCollection.cs / 1 / WebPartCollection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls.WebParts { using System; using System.Collections; using System.Diagnostics; using System.Globalization; using System.Security.Permissions; ////// Read-only collection of WebParts. Collection cannot be modified after contstruction. /// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class WebPartCollection : ReadOnlyCollectionBase { public WebPartCollection() { } public WebPartCollection(ICollection webParts) { if (webParts == null) { throw new ArgumentNullException("webParts"); } foreach (object obj in webParts) { if (obj == null) { throw new ArgumentException(SR.GetString(SR.Collection_CantAddNull), "webParts"); } if (!(obj is WebPart)) { throw new ArgumentException(SR.GetString(SR.Collection_InvalidType, "WebPart"), "webParts"); } InnerList.Add(obj); } } internal int Add(WebPart value) { Debug.Assert(value != null); return InnerList.Add(value); } public bool Contains(WebPart value) { return InnerList.Contains(value); } public int IndexOf(WebPart value) { return InnerList.IndexOf(value); } public WebPart this[int index] { get { return (WebPart) InnerList[index]; } } ////// Returns the WebPart with the specified id, or the GenericWebPart containing a control with /// the specified id, or the ProxyWebPart with OriginalID or GenericWebPartID equal to the /// specified id, performing a case-insensitive comparison. Returns null if there are no matches. /// public WebPart this[string id] { // PERF: Use a hashtable for lookup, instead of a linear search get { foreach (WebPart webPart in InnerList) { if (String.Equals(webPart.ID, id, StringComparison.OrdinalIgnoreCase)) { return webPart; } GenericWebPart genericWebPart = webPart as GenericWebPart; if (genericWebPart != null) { Control control = genericWebPart.ChildControl; if (control != null) { if (String.Equals(control.ID, id, StringComparison.OrdinalIgnoreCase)) { return genericWebPart; } } } ProxyWebPart proxyWebPart = webPart as ProxyWebPart; if (proxyWebPart != null) { if ((String.Equals(proxyWebPart.OriginalID, id, StringComparison.OrdinalIgnoreCase)) || (String.Equals(proxyWebPart.GenericWebPartID, id, StringComparison.OrdinalIgnoreCase))) { return proxyWebPart; } } } return null; } } ////// public void CopyTo(WebPart[] array, int index) { InnerList.CopyTo(array, index); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //Copies contents from the collection to a specified array with a /// specified starting index. ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls.WebParts { using System; using System.Collections; using System.Diagnostics; using System.Globalization; using System.Security.Permissions; ////// Read-only collection of WebParts. Collection cannot be modified after contstruction. /// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] public sealed class WebPartCollection : ReadOnlyCollectionBase { public WebPartCollection() { } public WebPartCollection(ICollection webParts) { if (webParts == null) { throw new ArgumentNullException("webParts"); } foreach (object obj in webParts) { if (obj == null) { throw new ArgumentException(SR.GetString(SR.Collection_CantAddNull), "webParts"); } if (!(obj is WebPart)) { throw new ArgumentException(SR.GetString(SR.Collection_InvalidType, "WebPart"), "webParts"); } InnerList.Add(obj); } } internal int Add(WebPart value) { Debug.Assert(value != null); return InnerList.Add(value); } public bool Contains(WebPart value) { return InnerList.Contains(value); } public int IndexOf(WebPart value) { return InnerList.IndexOf(value); } public WebPart this[int index] { get { return (WebPart) InnerList[index]; } } ////// Returns the WebPart with the specified id, or the GenericWebPart containing a control with /// the specified id, or the ProxyWebPart with OriginalID or GenericWebPartID equal to the /// specified id, performing a case-insensitive comparison. Returns null if there are no matches. /// public WebPart this[string id] { // PERF: Use a hashtable for lookup, instead of a linear search get { foreach (WebPart webPart in InnerList) { if (String.Equals(webPart.ID, id, StringComparison.OrdinalIgnoreCase)) { return webPart; } GenericWebPart genericWebPart = webPart as GenericWebPart; if (genericWebPart != null) { Control control = genericWebPart.ChildControl; if (control != null) { if (String.Equals(control.ID, id, StringComparison.OrdinalIgnoreCase)) { return genericWebPart; } } } ProxyWebPart proxyWebPart = webPart as ProxyWebPart; if (proxyWebPart != null) { if ((String.Equals(proxyWebPart.OriginalID, id, StringComparison.OrdinalIgnoreCase)) || (String.Equals(proxyWebPart.GenericWebPartID, id, StringComparison.OrdinalIgnoreCase))) { return proxyWebPart; } } } return null; } } ////// public void CopyTo(WebPart[] array, int index) { InnerList.CopyTo(array, index); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.Copies contents from the collection to a specified array with a /// specified starting index. ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DesignerHost.cs
- SapiRecognizer.cs
- Sorting.cs
- MessageFormatterConverter.cs
- CommonDialog.cs
- SQLMoney.cs
- RawStylusActions.cs
- SystemUdpStatistics.cs
- PropertyFilterAttribute.cs
- FormsAuthenticationModule.cs
- WebRequestModuleElementCollection.cs
- BindingElement.cs
- IsolatedStorage.cs
- MetadataArtifactLoader.cs
- SmiRecordBuffer.cs
- IgnoreDataMemberAttribute.cs
- ListControlConvertEventArgs.cs
- PartialTrustVisibleAssembliesSection.cs
- SmiContext.cs
- WebControlAdapter.cs
- EmptyEnumerator.cs
- MD5CryptoServiceProvider.cs
- DataGridViewBand.cs
- RadioButtonFlatAdapter.cs
- IDQuery.cs
- SvcFileManager.cs
- QuaternionAnimationBase.cs
- ThicknessAnimation.cs
- WebPartEditorOkVerb.cs
- PartitionedDataSource.cs
- BulletedListEventArgs.cs
- DockAndAnchorLayout.cs
- PathGeometry.cs
- CalendarAutoFormatDialog.cs
- DataSourceControlBuilder.cs
- ProfileGroupSettings.cs
- MinMaxParagraphWidth.cs
- ModifierKeysValueSerializer.cs
- Timer.cs
- TypeElementCollection.cs
- PropertyGridView.cs
- HelloOperationAsyncResult.cs
- RtfToken.cs
- PcmConverter.cs
- DefaultHttpHandler.cs
- SerializationObjectManager.cs
- DaylightTime.cs
- HitTestParameters.cs
- UInt32Converter.cs
- SmiRecordBuffer.cs
- GridView.cs
- XmlTextReaderImpl.cs
- TextViewElement.cs
- ExportOptions.cs
- ToggleButton.cs
- Cursors.cs
- BamlMapTable.cs
- ControlUtil.cs
- CacheAxisQuery.cs
- WebScriptEnablingBehavior.cs
- Command.cs
- GridToolTip.cs
- LinqDataSource.cs
- ILGen.cs
- SqlDataSourceSelectingEventArgs.cs
- RijndaelManaged.cs
- RawUIStateInputReport.cs
- XmlSerializerFactory.cs
- HitTestDrawingContextWalker.cs
- SafeBitVector32.cs
- TextRange.cs
- ContentType.cs
- SettingsBindableAttribute.cs
- TagMapCollection.cs
- TextEditorThreadLocalStore.cs
- BackStopAuthenticationModule.cs
- AsymmetricKeyExchangeDeformatter.cs
- ElementHostAutomationPeer.cs
- SpecialFolderEnumConverter.cs
- SystemKeyConverter.cs
- ClockGroup.cs
- QueryStringParameter.cs
- ViewStateException.cs
- ProcessInfo.cs
- MailHeaderInfo.cs
- SmiXetterAccessMap.cs
- MouseEvent.cs
- ParserStreamGeometryContext.cs
- SchemeSettingElement.cs
- DateTimeValueSerializerContext.cs
- Trace.cs
- FilterableData.cs
- TextViewBase.cs
- StreamReader.cs
- ServiceBehaviorElement.cs
- CreateUserWizardStep.cs
- SystemWebExtensionsSectionGroup.cs
- MobileControlsSectionHelper.cs
- DeviceSpecificDesigner.cs
- TypeNameConverter.cs