Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebParts / WebPartTracker.cs / 1305376 / WebPartTracker.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls.WebParts {
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing.Design;
using System.Web;
using System.Web.UI;
public sealed class WebPartTracker : IDisposable {
private bool _disposed;
private WebPart _webPart;
private ProviderConnectionPoint _providerConnectionPoint;
public WebPartTracker(WebPart webPart, ProviderConnectionPoint providerConnectionPoint) {
if (webPart == null) {
throw new ArgumentNullException("webPart");
}
if (providerConnectionPoint == null) {
throw new ArgumentNullException("providerConnectionPoint");
}
if (providerConnectionPoint.ControlType != webPart.GetType()) {
throw new ArgumentException(SR.GetString(SR.WebPartManager_InvalidConnectionPoint), "providerConnectionPoint");
}
_webPart = webPart;
_providerConnectionPoint = providerConnectionPoint;
if (++Count > 1) {
webPart.SetConnectErrorMessage(SR.GetString(
SR.WebPartTracker_CircularConnection, _providerConnectionPoint.DisplayName));
}
}
public bool IsCircularConnection {
get {
return (Count > 1);
}
}
private int Count {
get {
int count;
_webPart.TrackerCounter.TryGetValue(_providerConnectionPoint, out count);
return count;
}
set {
_webPart.TrackerCounter[_providerConnectionPoint] = value;
}
}
void IDisposable.Dispose() {
if (!_disposed) {
Debug.Assert(Count >= 1);
Count--;
_disposed = 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.Diagnostics;
using System.Drawing.Design;
using System.Web;
using System.Web.UI;
public sealed class WebPartTracker : IDisposable {
private bool _disposed;
private WebPart _webPart;
private ProviderConnectionPoint _providerConnectionPoint;
public WebPartTracker(WebPart webPart, ProviderConnectionPoint providerConnectionPoint) {
if (webPart == null) {
throw new ArgumentNullException("webPart");
}
if (providerConnectionPoint == null) {
throw new ArgumentNullException("providerConnectionPoint");
}
if (providerConnectionPoint.ControlType != webPart.GetType()) {
throw new ArgumentException(SR.GetString(SR.WebPartManager_InvalidConnectionPoint), "providerConnectionPoint");
}
_webPart = webPart;
_providerConnectionPoint = providerConnectionPoint;
if (++Count > 1) {
webPart.SetConnectErrorMessage(SR.GetString(
SR.WebPartTracker_CircularConnection, _providerConnectionPoint.DisplayName));
}
}
public bool IsCircularConnection {
get {
return (Count > 1);
}
}
private int Count {
get {
int count;
_webPart.TrackerCounter.TryGetValue(_providerConnectionPoint, out count);
return count;
}
set {
_webPart.TrackerCounter[_providerConnectionPoint] = value;
}
}
void IDisposable.Dispose() {
if (!_disposed) {
Debug.Assert(Count >= 1);
Count--;
_disposed = 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
- SoapEnumAttribute.cs
- InvalidProgramException.cs
- NativeWindow.cs
- EmptyStringExpandableObjectConverter.cs
- ChangeProcessor.cs
- TextElementEditingBehaviorAttribute.cs
- LicenseProviderAttribute.cs
- SiteMap.cs
- ImmComposition.cs
- x509store.cs
- ItemList.cs
- EntityRecordInfo.cs
- FileStream.cs
- COM2ExtendedTypeConverter.cs
- ToolTipService.cs
- HttpsHostedTransportConfiguration.cs
- RegionInfo.cs
- SecurityUniqueId.cs
- HTMLTagNameToTypeMapper.cs
- CodeCastExpression.cs
- FlowLayoutPanel.cs
- invalidudtexception.cs
- SmtpMail.cs
- FastEncoderWindow.cs
- TemplateGroupCollection.cs
- PersonalizationDictionary.cs
- CapiSafeHandles.cs
- TextParentUndoUnit.cs
- URLAttribute.cs
- DPTypeDescriptorContext.cs
- CheckBox.cs
- SpoolingTask.cs
- SchemaMerger.cs
- KeyValuePair.cs
- SmtpDateTime.cs
- SchemaName.cs
- QueueException.cs
- OleDbException.cs
- FrameDimension.cs
- DecoderBestFitFallback.cs
- PreProcessInputEventArgs.cs
- UpdatableGenericsFeature.cs
- Msec.cs
- ProviderConnectionPointCollection.cs
- _Rfc2616CacheValidators.cs
- TypeValidationEventArgs.cs
- InputProcessorProfilesLoader.cs
- UpdateDelegates.Generated.cs
- WebPageTraceListener.cs
- PerspectiveCamera.cs
- TextSelectionHighlightLayer.cs
- TextServicesDisplayAttribute.cs
- Visual3DCollection.cs
- SerializationInfo.cs
- SpeechUI.cs
- FrameSecurityDescriptor.cs
- AQNBuilder.cs
- DataGridCellsPanel.cs
- AsyncInvokeContext.cs
- ASCIIEncoding.cs
- ObjectListField.cs
- FrameSecurityDescriptor.cs
- WindowsStreamSecurityUpgradeProvider.cs
- RootBrowserWindow.cs
- XMLDiffLoader.cs
- SaveFileDialog.cs
- QilVisitor.cs
- ProfileSettings.cs
- EntityConnection.cs
- SqlInfoMessageEvent.cs
- PreservationFileWriter.cs
- SplineQuaternionKeyFrame.cs
- MetadataPropertyAttribute.cs
- COM2PropertyBuilderUITypeEditor.cs
- HttpsHostedTransportConfiguration.cs
- XmlKeywords.cs
- DataSourceView.cs
- ConfigurationPropertyCollection.cs
- WebDescriptionAttribute.cs
- Assert.cs
- ACE.cs
- IndexedEnumerable.cs
- TextSegment.cs
- TabItemWrapperAutomationPeer.cs
- ProxyWebPartConnectionCollection.cs
- WindowsMenu.cs
- ExpressionsCollectionEditor.cs
- DefaultShape.cs
- GcHandle.cs
- ExpressionBuilder.cs
- RSACryptoServiceProvider.cs
- FirewallWrapper.cs
- JournalEntryListConverter.cs
- TranslateTransform3D.cs
- SmiEventSink_Default.cs
- UnauthorizedAccessException.cs
- WindowsButton.cs
- AuthorizationRuleCollection.cs
- SmtpNetworkElement.cs
- _SSPIWrapper.cs