Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- PropertyDescriptorCollection.cs
- TopClause.cs
- MetafileEditor.cs
- Stackframe.cs
- PersonalizationEntry.cs
- ComboBoxItem.cs
- FormParameter.cs
- ResolveNameEventArgs.cs
- TypeUtil.cs
- RawStylusInputCustomDataList.cs
- updatecommandorderer.cs
- HtmlElementErrorEventArgs.cs
- EqualityComparer.cs
- SchemaDeclBase.cs
- DriveNotFoundException.cs
- EngineSite.cs
- Panel.cs
- DeclarationUpdate.cs
- CustomExpressionEventArgs.cs
- PageThemeParser.cs
- ArrayList.cs
- TreeViewAutomationPeer.cs
- BasicCellRelation.cs
- ToolStripScrollButton.cs
- SqlBuilder.cs
- TextEndOfParagraph.cs
- VirtualStackFrame.cs
- ProjectionPlanCompiler.cs
- CodeTypeParameter.cs
- MenuItemCollection.cs
- CipherData.cs
- AutoGeneratedField.cs
- MembershipSection.cs
- ISFTagAndGuidCache.cs
- EntitySqlQueryCacheEntry.cs
- StateRuntime.cs
- RectangleGeometry.cs
- VirtualPath.cs
- IndexedString.cs
- CustomSignedXml.cs
- CatalogPartChrome.cs
- SimplePropertyEntry.cs
- XmlIgnoreAttribute.cs
- dataprotectionpermissionattribute.cs
- Point.cs
- ListViewEditEventArgs.cs
- IgnoreDataMemberAttribute.cs
- ipaddressinformationcollection.cs
- SystemException.cs
- SplineKeyFrames.cs
- TextSelectionHighlightLayer.cs
- AnnotationDocumentPaginator.cs
- WeakHashtable.cs
- AbandonedMutexException.cs
- StringReader.cs
- DictionaryItemsCollection.cs
- HashCryptoHandle.cs
- BinHexEncoder.cs
- MsmqHostedTransportConfiguration.cs
- ProgressBarRenderer.cs
- ProjectionAnalyzer.cs
- Shape.cs
- PassportPrincipal.cs
- XmlEntityReference.cs
- TypedServiceOperationListItem.cs
- SchemaTableOptionalColumn.cs
- TaskExtensions.cs
- OleDbParameter.cs
- RuntimeConfigurationRecord.cs
- UpdateTracker.cs
- ImmutableDispatchRuntime.cs
- ElapsedEventArgs.cs
- ObfuscateAssemblyAttribute.cs
- XPathNavigatorKeyComparer.cs
- XmlWriterTraceListener.cs
- XmlQuerySequence.cs
- WindowInteropHelper.cs
- FileStream.cs
- InputLangChangeRequestEvent.cs
- SemanticBasicElement.cs
- XamlTreeBuilderBamlRecordWriter.cs
- ICspAsymmetricAlgorithm.cs
- PersonalizationStateInfoCollection.cs
- ShapeTypeface.cs
- GeneralTransform3D.cs
- HttpFileCollection.cs
- SqlVersion.cs
- CheckedPointers.cs
- XPathNavigatorReader.cs
- LogSwitch.cs
- FormsAuthenticationCredentials.cs
- PhonemeEventArgs.cs
- DbSourceParameterCollection.cs
- ASCIIEncoding.cs
- base64Transforms.cs
- XmlILConstructAnalyzer.cs
- DynamicDocumentPaginator.cs
- DataGridDetailsPresenter.cs
- RootProfilePropertySettingsCollection.cs
- ManifestResourceInfo.cs