Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / CompMod / System / ComponentModel / EventHandlerList.cs / 1 / EventHandlerList.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.ComponentModel { using System; using System.Diagnostics.CodeAnalysis; using System.Security.Permissions; ////// [HostProtection(SharedState = true)] public sealed class EventHandlerList : IDisposable { ListEntry head; Component parent; ///Provides a simple list of delegates. This class cannot be inherited. ////// Creates a new event handler list. /// [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] public EventHandlerList() { } ////// Creates a new event handler list. The parent component is used to check the component's /// CanRaiseEvents property. /// [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] internal EventHandlerList(Component parent) { this.parent = parent; } ////// public Delegate this[object key] { [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] get { ListEntry e = null; if (parent == null || parent.CanRaiseEventsInternal) { e = Find(key); } if (e != null) { return e.handler; } else { return null; } } set { ListEntry e = Find(key); if (e != null) { e.handler = value; } else { head = new ListEntry(key, value, head); } } } ///Gets or sets the delegate for the specified key. ////// [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] public void AddHandler(object key, Delegate value) { ListEntry e = Find(key); if (e != null) { e.handler = Delegate.Combine(e.handler, value); } else { head = new ListEntry(key, value, head); } } ///[To be supplied.] ///allows you to add a list of events to this list public void AddHandlers(EventHandlerList listToAddFrom) { ListEntry currentListEntry = listToAddFrom.head; while (currentListEntry != null) { AddHandler(currentListEntry.key, currentListEntry.handler); currentListEntry = currentListEntry.next; } } ////// public void Dispose() { head = null; } private ListEntry Find(object key) { ListEntry found = head; while (found != null) { if (found.key == key) { break; } found = found.next; } return found; } ///[To be supplied.] ////// [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] public void RemoveHandler(object key, Delegate value) { ListEntry e = Find(key); if (e != null) { e.handler = Delegate.Remove(e.handler, value); } // else... no error for removal of non-existant delegate // } private sealed class ListEntry { internal ListEntry next; internal object key; internal Delegate handler; public ListEntry(object key, Delegate handler, ListEntry next) { this.next = next; this.key = key; this.handler = handler; } } } }[To be supplied.] ///
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CompileXomlTask.cs
- FlowchartDesignerCommands.cs
- Console.cs
- KnownTypeAttribute.cs
- GiveFeedbackEventArgs.cs
- DetailsView.cs
- BrowserCapabilitiesFactoryBase.cs
- util.cs
- ButtonBase.cs
- FormsAuthenticationConfiguration.cs
- CurrentTimeZone.cs
- AliasGenerator.cs
- RegexRunner.cs
- ConstraintCollection.cs
- PenLineCapValidation.cs
- FacetDescriptionElement.cs
- DrawingCollection.cs
- LinkUtilities.cs
- DesignerOptionService.cs
- LogEntryDeserializer.cs
- LabelEditEvent.cs
- SimpleRecyclingCache.cs
- QuadraticBezierSegment.cs
- ModuleBuilderData.cs
- MailAddressParser.cs
- XmlValidatingReader.cs
- UpdatePanel.cs
- IPAddress.cs
- AspProxy.cs
- FontWeight.cs
- ThicknessConverter.cs
- TemplateEditingService.cs
- DataFormats.cs
- StreamGeometry.cs
- invalidudtexception.cs
- ExpandCollapsePattern.cs
- TextSegment.cs
- ValidatorCollection.cs
- ResourceFallbackManager.cs
- PersonalizationEntry.cs
- ExtenderProvidedPropertyAttribute.cs
- PolicyUnit.cs
- Html32TextWriter.cs
- ActivationArguments.cs
- Parameter.cs
- VerificationAttribute.cs
- FontFamily.cs
- TypefaceMap.cs
- HtmlInputButton.cs
- CustomAttributeFormatException.cs
- RtfControls.cs
- ConfigPathUtility.cs
- FloatAverageAggregationOperator.cs
- ServiceParser.cs
- DrawingServices.cs
- AppendHelper.cs
- Pool.cs
- GeneralTransform3DTo2D.cs
- WindowsSlider.cs
- PasswordRecovery.cs
- GridSplitterAutomationPeer.cs
- MatrixIndependentAnimationStorage.cs
- ProcessProtocolHandler.cs
- TypeNameConverter.cs
- PropertyTab.cs
- LinqDataSourceContextData.cs
- nulltextnavigator.cs
- InArgument.cs
- ErrorWebPart.cs
- ProcessManager.cs
- FixedPageProcessor.cs
- OleServicesContext.cs
- SplayTreeNode.cs
- TextView.cs
- PrimitiveSchema.cs
- SmtpClient.cs
- CommandConverter.cs
- TabControlToolboxItem.cs
- ScopelessEnumAttribute.cs
- DbConnectionPoolIdentity.cs
- CheckBox.cs
- Triangle.cs
- ipaddressinformationcollection.cs
- XmlDataLoader.cs
- ToolStripRenderer.cs
- CollectionConverter.cs
- PartialCachingControl.cs
- COM2Properties.cs
- Table.cs
- WasAdminWrapper.cs
- IgnoreFlushAndCloseStream.cs
- Expressions.cs
- ACL.cs
- TextCompositionEventArgs.cs
- FocusChangedEventArgs.cs
- ReadOnlyDictionary.cs
- TextRange.cs
- TemplateKey.cs
- FilteredAttributeCollection.cs
- MultiAsyncResult.cs