Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebParts / WebPartCollection.cs / 1305376 / 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; ////// Read-only collection of WebParts. Collection cannot be modified after contstruction. /// 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; ////// Read-only collection of WebParts. Collection cannot be modified after contstruction. /// 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
- SelectionProcessor.cs
- XmlNodeComparer.cs
- LinkArea.cs
- EventData.cs
- SafeHandles.cs
- FrameworkName.cs
- TypeGeneratedEventArgs.cs
- PageAsyncTask.cs
- X509UI.cs
- DirectoryObjectSecurity.cs
- ColumnCollection.cs
- DataGridTextBoxColumn.cs
- WebPartUserCapability.cs
- TextRangeSerialization.cs
- Thumb.cs
- NamedPipeDuplicateContext.cs
- HtmlFormWrapper.cs
- CSharpCodeProvider.cs
- CompiledAction.cs
- SqlNodeAnnotations.cs
- BrowserTree.cs
- EndpointAddressMessageFilterTable.cs
- DataSourceCache.cs
- OdbcConnectionStringbuilder.cs
- Walker.cs
- StorageAssociationSetMapping.cs
- DateBoldEvent.cs
- DropSource.cs
- DmlSqlGenerator.cs
- EndEvent.cs
- RequestCacheValidator.cs
- MDIWindowDialog.cs
- XmlHierarchicalEnumerable.cs
- SafeUserTokenHandle.cs
- CheckoutException.cs
- UshortList2.cs
- SymbolEqualComparer.cs
- DecodeHelper.cs
- SqlUserDefinedAggregateAttribute.cs
- UntypedNullExpression.cs
- RewritingSimplifier.cs
- UnicastIPAddressInformationCollection.cs
- ContextStaticAttribute.cs
- StringAnimationBase.cs
- OptimalBreakSession.cs
- NoResizeSelectionBorderGlyph.cs
- FormViewDeleteEventArgs.cs
- AnnouncementService.cs
- ZipIOCentralDirectoryBlock.cs
- AliasGenerator.cs
- Number.cs
- TraceSection.cs
- UTF32Encoding.cs
- SafeNativeMethods.cs
- Delegate.cs
- GenerateScriptTypeAttribute.cs
- CookieProtection.cs
- HashAlgorithm.cs
- Latin1Encoding.cs
- WebPartZoneBase.cs
- PreApplicationStartMethodAttribute.cs
- XmlDataCollection.cs
- CompiledAction.cs
- FuncCompletionCallbackWrapper.cs
- HwndSourceParameters.cs
- TypeToken.cs
- ListViewGroupConverter.cs
- MethodCallConverter.cs
- GroupAggregateExpr.cs
- PartialTrustVisibleAssemblyCollection.cs
- XmlUtilWriter.cs
- UnsafeNativeMethods.cs
- Win32SafeHandles.cs
- ObfuscationAttribute.cs
- CallbackBehaviorAttribute.cs
- __TransparentProxy.cs
- FormViewInsertedEventArgs.cs
- Msec.cs
- PrivateFontCollection.cs
- DBConnectionString.cs
- UnsafeNativeMethods.cs
- MemberAccessException.cs
- QueryableDataSource.cs
- IdentityValidationException.cs
- Parallel.cs
- COM2EnumConverter.cs
- LocalizableResourceBuilder.cs
- FixedSOMTableCell.cs
- IdlingCommunicationPool.cs
- TypeSystem.cs
- Baml2006ReaderContext.cs
- MeasureData.cs
- ValidationRuleCollection.cs
- OleDbParameter.cs
- Soap12FormatExtensions.cs
- TextRunCache.cs
- DelayDesigner.cs
- VisualCollection.cs
- CustomTypeDescriptor.cs
- ValidatorCompatibilityHelper.cs