Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebParts / WebPartConnectionCollection.cs / 1305376 / WebPartConnectionCollection.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls.WebParts {
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing.Design;
using System.Globalization;
using System.Web.Util;
//
[
Editor("System.ComponentModel.Design.CollectionEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor))
]
public sealed class WebPartConnectionCollection : CollectionBase {
private bool _readOnly;
private string _readOnlyExceptionMessage;
private WebPartManager _webPartManager;
internal WebPartConnectionCollection(WebPartManager webPartManager) {
_webPartManager = webPartManager;
}
public bool IsReadOnly {
get {
return _readOnly;
}
}
///
/// Returns the WebPartConnection at a given index.
///
public WebPartConnection this[int index] {
get {
return (WebPartConnection)List[index];
}
set {
List[index] = value;
}
}
///
/// Returns the WebPartConnection with the specified id, performing a case-insensitive comparison.
/// Returns null if there are no matches.
///
public WebPartConnection this[string id] {
// PERF: Use a hashtable for lookup, instead of a linear search
get {
foreach (WebPartConnection connection in List) {
if (String.Equals(connection.ID, id, StringComparison.OrdinalIgnoreCase)) {
return connection;
}
}
return null;
}
}
///
/// Adds a Connection to the collection.
///
public int Add(WebPartConnection value) {
return List.Add(value);
}
private void CheckReadOnly() {
if (_readOnly) {
throw new InvalidOperationException(SR.GetString(_readOnlyExceptionMessage));
}
}
///
/// True if the WebPartConnection is contained in the collection.
///
public bool Contains(WebPartConnection value) {
return List.Contains(value);
}
internal bool ContainsProvider(WebPart provider) {
foreach (WebPartConnection connection in List) {
if (connection.Provider == provider) {
return true;
}
}
return false;
}
public void CopyTo(WebPartConnection[] array, int index) {
List.CopyTo(array, index);
}
public int IndexOf(WebPartConnection value) {
return List.IndexOf(value);
}
///
/// Inserts a WebPartConnection into the collection.
///
public void Insert(int index, WebPartConnection value) {
List.Insert(index, value);
}
///
///
protected override void OnClear() {
CheckReadOnly();
base.OnClear();
}
protected override void OnInsert(int index, object value) {
CheckReadOnly();
((WebPartConnection)value).SetWebPartManager(_webPartManager);
base.OnInsert(index, value);
}
protected override void OnRemove(int index, object value) {
CheckReadOnly();
((WebPartConnection)value).SetWebPartManager(null);
base.OnRemove(index, value);
}
protected override void OnSet(int index, object oldValue, object newValue) {
CheckReadOnly();
((WebPartConnection)oldValue).SetWebPartManager(null);
((WebPartConnection)newValue).SetWebPartManager(_webPartManager);
base.OnSet(index, oldValue, newValue);
}
///
/// Validates that an object is a WebPartConnection.
///
protected override void OnValidate(object value) {
base.OnValidate(value);
if (value == null) {
throw new ArgumentNullException("value", SR.GetString(SR.Collection_CantAddNull));
}
if (!(value is WebPartConnection)) {
throw new ArgumentException(SR.GetString(SR.Collection_InvalidType, "WebPartConnection"), "value");
}
}
///
/// Removes a WebPartConnection from the collection.
///
public void Remove(WebPartConnection value) {
List.Remove(value);
}
///
/// Marks the collection readonly. This is useful, because we assume that the list
/// of static connections is known at Init time, and new connections are added
/// through the WebPartManager.
///
internal void SetReadOnly(string exceptionMessage) {
_readOnlyExceptionMessage = exceptionMessage;
_readOnly = true;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls.WebParts {
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing.Design;
using System.Globalization;
using System.Web.Util;
//
[
Editor("System.ComponentModel.Design.CollectionEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor))
]
public sealed class WebPartConnectionCollection : CollectionBase {
private bool _readOnly;
private string _readOnlyExceptionMessage;
private WebPartManager _webPartManager;
internal WebPartConnectionCollection(WebPartManager webPartManager) {
_webPartManager = webPartManager;
}
public bool IsReadOnly {
get {
return _readOnly;
}
}
///
/// Returns the WebPartConnection at a given index.
///
public WebPartConnection this[int index] {
get {
return (WebPartConnection)List[index];
}
set {
List[index] = value;
}
}
///
/// Returns the WebPartConnection with the specified id, performing a case-insensitive comparison.
/// Returns null if there are no matches.
///
public WebPartConnection this[string id] {
// PERF: Use a hashtable for lookup, instead of a linear search
get {
foreach (WebPartConnection connection in List) {
if (String.Equals(connection.ID, id, StringComparison.OrdinalIgnoreCase)) {
return connection;
}
}
return null;
}
}
///
/// Adds a Connection to the collection.
///
public int Add(WebPartConnection value) {
return List.Add(value);
}
private void CheckReadOnly() {
if (_readOnly) {
throw new InvalidOperationException(SR.GetString(_readOnlyExceptionMessage));
}
}
///
/// True if the WebPartConnection is contained in the collection.
///
public bool Contains(WebPartConnection value) {
return List.Contains(value);
}
internal bool ContainsProvider(WebPart provider) {
foreach (WebPartConnection connection in List) {
if (connection.Provider == provider) {
return true;
}
}
return false;
}
public void CopyTo(WebPartConnection[] array, int index) {
List.CopyTo(array, index);
}
public int IndexOf(WebPartConnection value) {
return List.IndexOf(value);
}
///
/// Inserts a WebPartConnection into the collection.
///
public void Insert(int index, WebPartConnection value) {
List.Insert(index, value);
}
///
///
protected override void OnClear() {
CheckReadOnly();
base.OnClear();
}
protected override void OnInsert(int index, object value) {
CheckReadOnly();
((WebPartConnection)value).SetWebPartManager(_webPartManager);
base.OnInsert(index, value);
}
protected override void OnRemove(int index, object value) {
CheckReadOnly();
((WebPartConnection)value).SetWebPartManager(null);
base.OnRemove(index, value);
}
protected override void OnSet(int index, object oldValue, object newValue) {
CheckReadOnly();
((WebPartConnection)oldValue).SetWebPartManager(null);
((WebPartConnection)newValue).SetWebPartManager(_webPartManager);
base.OnSet(index, oldValue, newValue);
}
///
/// Validates that an object is a WebPartConnection.
///
protected override void OnValidate(object value) {
base.OnValidate(value);
if (value == null) {
throw new ArgumentNullException("value", SR.GetString(SR.Collection_CantAddNull));
}
if (!(value is WebPartConnection)) {
throw new ArgumentException(SR.GetString(SR.Collection_InvalidType, "WebPartConnection"), "value");
}
}
///
/// Removes a WebPartConnection from the collection.
///
public void Remove(WebPartConnection value) {
List.Remove(value);
}
///
/// Marks the collection readonly. This is useful, because we assume that the list
/// of static connections is known at Init time, and new connections are added
/// through the WebPartManager.
///
internal void SetReadOnly(string exceptionMessage) {
_readOnlyExceptionMessage = exceptionMessage;
_readOnly = true;
}
}
}
// 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
- cookie.cs
- View.cs
- IIS7WorkerRequest.cs
- MessageQueueCriteria.cs
- PerformanceCountersElement.cs
- AssemblyContextControlItem.cs
- ParallelQuery.cs
- DispatcherExceptionFilterEventArgs.cs
- embossbitmapeffect.cs
- FontStyle.cs
- StreamGeometryContext.cs
- XmlSchemaSimpleContent.cs
- BrowserCapabilitiesCompiler.cs
- ClosableStream.cs
- XamlTypeWithExplicitNamespace.cs
- WeakEventManager.cs
- TraceSwitch.cs
- SafeMarshalContext.cs
- SecurityTokenSpecification.cs
- InkCanvasSelectionAdorner.cs
- XmlNodeChangedEventArgs.cs
- CredentialCache.cs
- WorkflowIdleBehavior.cs
- Floater.cs
- KeyedCollection.cs
- RelationshipManager.cs
- KeyValueConfigurationCollection.cs
- ImageButton.cs
- ExpressionConverter.cs
- AutomationPatternInfo.cs
- CodeVariableReferenceExpression.cs
- WindowsImpersonationContext.cs
- DeclarationUpdate.cs
- DocumentApplication.cs
- GridViewRowPresenterBase.cs
- SymbolMethod.cs
- ButtonFieldBase.cs
- QuotedPrintableStream.cs
- HttpConfigurationSystem.cs
- ViewCellSlot.cs
- cookie.cs
- LoginUtil.cs
- DataGridCaption.cs
- CachedPathData.cs
- DeploymentExceptionMapper.cs
- EntityDataSourceDesigner.cs
- ScriptingScriptResourceHandlerSection.cs
- Operand.cs
- NativeCppClassAttribute.cs
- TextElementAutomationPeer.cs
- TreeNodeMouseHoverEvent.cs
- SystemIPGlobalProperties.cs
- HttpDebugHandler.cs
- ConfigurationElement.cs
- handlecollector.cs
- HttpInputStream.cs
- ScrollProperties.cs
- CultureInfoConverter.cs
- ColumnWidthChangingEvent.cs
- PeerCustomResolverBindingElement.cs
- OracleBoolean.cs
- FrameworkElementFactory.cs
- RecognitionResult.cs
- Application.cs
- ThreadAttributes.cs
- XslAstAnalyzer.cs
- XdrBuilder.cs
- HostExecutionContextManager.cs
- FirstMatchCodeGroup.cs
- objectresult_tresulttype.cs
- XhtmlConformanceSection.cs
- Visual3DCollection.cs
- DispatcherExceptionFilterEventArgs.cs
- EventArgs.cs
- Scalars.cs
- FileClassifier.cs
- TraversalRequest.cs
- EllipseGeometry.cs
- FixedDSBuilder.cs
- ValidationHelpers.cs
- SQLChars.cs
- SQLMembershipProvider.cs
- SelectionEditor.cs
- GreenMethods.cs
- SQLSingleStorage.cs
- CurrentChangingEventArgs.cs
- PanelDesigner.cs
- Encoding.cs
- QueueSurrogate.cs
- ModelChangedEventArgsImpl.cs
- updatecommandorderer.cs
- RIPEMD160.cs
- SystemInfo.cs
- SchemaCollectionCompiler.cs
- SoapAttributes.cs
- XpsSerializationManagerAsync.cs
- PrintPageEvent.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- WebBrowsableAttribute.cs
- ImageConverter.cs