Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / RoutedEventHandlerInfo.cs / 1 / RoutedEventHandlerInfo.cs
using System;
namespace System.Windows
{
///
/// Container for handler instance and other
/// invocation preferences for this handler
/// instance
///
///
/// RoutedEventHandlerInfo constitutes the
/// handler instance and flag that indicates if
/// or not this handler must be invoked for
/// already handled events
///
///
/// This class needs to be public because it is
/// used by ContentElement in the Framework
/// to store Instance EventHandlers
///
//CASRemoval:[StrongNameIdentityPermission(SecurityAction.LinkDemand, PublicKey = Microsoft.Internal.BuildInfo.WCP_PUBLIC_KEY_STRING)]
public struct RoutedEventHandlerInfo
{
#region Construction
///
/// Construtor for RoutedEventHandlerInfo
///
///
/// Non-null handler
///
///
/// Flag that indicates if or not the handler must
/// be invoked for already handled events
///
internal RoutedEventHandlerInfo(Delegate handler, bool handledEventsToo)
{
_handler = handler;
_handledEventsToo = handledEventsToo;
}
#endregion Construction
#region Operations
///
/// Returns associated handler instance
///
public Delegate Handler
{
get {return _handler;}
}
///
/// Returns HandledEventsToo Flag
///
public bool InvokeHandledEventsToo
{
get {return _handledEventsToo;}
}
// Invokes handler instance as per specified
// invocation preferences
internal void InvokeHandler(object target, RoutedEventArgs routedEventArgs)
{
if ((routedEventArgs.Handled == false) || (_handledEventsToo == true))
{
if (_handler is RoutedEventHandler)
{
// Generic RoutedEventHandler is called directly here since
// we don't need the InvokeEventHandler override to cast to
// the proper type - we know what it is.
((RoutedEventHandler)_handler)(target, routedEventArgs);
}
else
{
// NOTE: Cannot call protected method InvokeEventHandler directly
routedEventArgs.InvokeHandler(_handler, target);
}
}
}
///
/// Is the given object equivalent to the current one
///
public override bool Equals(object obj)
{
if (obj == null || !(obj is RoutedEventHandlerInfo))
return false;
return Equals((RoutedEventHandlerInfo)obj);
}
///
/// Is the given RoutedEventHandlerInfo equals the current
///
public bool Equals(RoutedEventHandlerInfo handlerInfo)
{
return _handler == handlerInfo._handler && _handledEventsToo == handlerInfo._handledEventsToo;
}
///
/// Serves as a hash function for a particular type, suitable for use in
/// hashing algorithms and data structures like a hash table
///
public override int GetHashCode()
{
return base.GetHashCode();
}
///
/// Equals operator overload
///
public static bool operator== (RoutedEventHandlerInfo handlerInfo1, RoutedEventHandlerInfo handlerInfo2)
{
return handlerInfo1.Equals(handlerInfo2);
}
///
/// NotEquals operator overload
///
public static bool operator!= (RoutedEventHandlerInfo handlerInfo1, RoutedEventHandlerInfo handlerInfo2)
{
return !handlerInfo1.Equals(handlerInfo2);
}
///
/// Cleanup all the references within the data
///
/*
Commented out to avoid "uncalled private code" fxcop violation
internal void Clear()
{
_handler = null;
_handledEventsToo = false;
}
*/
#endregion Operations
#region Data
private Delegate _handler;
private bool _handledEventsToo;
#endregion Data
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
namespace System.Windows
{
///
/// Container for handler instance and other
/// invocation preferences for this handler
/// instance
///
///
/// RoutedEventHandlerInfo constitutes the
/// handler instance and flag that indicates if
/// or not this handler must be invoked for
/// already handled events
///
///
/// This class needs to be public because it is
/// used by ContentElement in the Framework
/// to store Instance EventHandlers
///
//CASRemoval:[StrongNameIdentityPermission(SecurityAction.LinkDemand, PublicKey = Microsoft.Internal.BuildInfo.WCP_PUBLIC_KEY_STRING)]
public struct RoutedEventHandlerInfo
{
#region Construction
///
/// Construtor for RoutedEventHandlerInfo
///
///
/// Non-null handler
///
///
/// Flag that indicates if or not the handler must
/// be invoked for already handled events
///
internal RoutedEventHandlerInfo(Delegate handler, bool handledEventsToo)
{
_handler = handler;
_handledEventsToo = handledEventsToo;
}
#endregion Construction
#region Operations
///
/// Returns associated handler instance
///
public Delegate Handler
{
get {return _handler;}
}
///
/// Returns HandledEventsToo Flag
///
public bool InvokeHandledEventsToo
{
get {return _handledEventsToo;}
}
// Invokes handler instance as per specified
// invocation preferences
internal void InvokeHandler(object target, RoutedEventArgs routedEventArgs)
{
if ((routedEventArgs.Handled == false) || (_handledEventsToo == true))
{
if (_handler is RoutedEventHandler)
{
// Generic RoutedEventHandler is called directly here since
// we don't need the InvokeEventHandler override to cast to
// the proper type - we know what it is.
((RoutedEventHandler)_handler)(target, routedEventArgs);
}
else
{
// NOTE: Cannot call protected method InvokeEventHandler directly
routedEventArgs.InvokeHandler(_handler, target);
}
}
}
///
/// Is the given object equivalent to the current one
///
public override bool Equals(object obj)
{
if (obj == null || !(obj is RoutedEventHandlerInfo))
return false;
return Equals((RoutedEventHandlerInfo)obj);
}
///
/// Is the given RoutedEventHandlerInfo equals the current
///
public bool Equals(RoutedEventHandlerInfo handlerInfo)
{
return _handler == handlerInfo._handler && _handledEventsToo == handlerInfo._handledEventsToo;
}
///
/// Serves as a hash function for a particular type, suitable for use in
/// hashing algorithms and data structures like a hash table
///
public override int GetHashCode()
{
return base.GetHashCode();
}
///
/// Equals operator overload
///
public static bool operator== (RoutedEventHandlerInfo handlerInfo1, RoutedEventHandlerInfo handlerInfo2)
{
return handlerInfo1.Equals(handlerInfo2);
}
///
/// NotEquals operator overload
///
public static bool operator!= (RoutedEventHandlerInfo handlerInfo1, RoutedEventHandlerInfo handlerInfo2)
{
return !handlerInfo1.Equals(handlerInfo2);
}
///
/// Cleanup all the references within the data
///
/*
Commented out to avoid "uncalled private code" fxcop violation
internal void Clear()
{
_handler = null;
_handledEventsToo = false;
}
*/
#endregion Operations
#region Data
private Delegate _handler;
private bool _handledEventsToo;
#endregion Data
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ServiceMetadataPublishingElement.cs
- ActiveXHost.cs
- FlowDecision.cs
- NavigationProperty.cs
- TextTreeDeleteContentUndoUnit.cs
- OleDbReferenceCollection.cs
- RegexNode.cs
- ValueConversionAttribute.cs
- TreeBuilder.cs
- DocumentViewerBase.cs
- SingleObjectCollection.cs
- VirtualDirectoryMapping.cs
- SamlSerializer.cs
- CommandField.cs
- ReferencedCollectionType.cs
- EventListener.cs
- NullRuntimeConfig.cs
- XDeferredAxisSource.cs
- PkcsUtils.cs
- AccessedThroughPropertyAttribute.cs
- SrgsItemList.cs
- EncryptedData.cs
- ExceptionHandlers.cs
- PageAsyncTask.cs
- IndexedString.cs
- Instrumentation.cs
- WindowCollection.cs
- LeftCellWrapper.cs
- Misc.cs
- TemplateComponentConnector.cs
- ContainsSearchOperator.cs
- AsynchronousChannelMergeEnumerator.cs
- Frame.cs
- SystemIPInterfaceProperties.cs
- InputBinding.cs
- MobileRedirect.cs
- BatchParser.cs
- DataSetMappper.cs
- Mapping.cs
- VectorAnimationUsingKeyFrames.cs
- EntityModelSchemaGenerator.cs
- XmlNode.cs
- StateWorkerRequest.cs
- TraceHandlerErrorFormatter.cs
- DataFieldConverter.cs
- XmlNullResolver.cs
- ToolBarTray.cs
- DebuggerAttributes.cs
- RSACryptoServiceProvider.cs
- Size3DValueSerializer.cs
- ParseNumbers.cs
- SchemaCompiler.cs
- CodeTypeReferenceCollection.cs
- TableProviderWrapper.cs
- DataGridViewRow.cs
- PeerIPHelper.cs
- HttpConfigurationContext.cs
- MatrixValueSerializer.cs
- ClientSettingsSection.cs
- EncoderExceptionFallback.cs
- StringToken.cs
- ExtensibleClassFactory.cs
- HtmlTableRow.cs
- VirtualPathUtility.cs
- SelectionListComponentEditor.cs
- SynchronizedDispatch.cs
- TdsParameterSetter.cs
- TagNameToTypeMapper.cs
- WebPartTransformerCollection.cs
- TextCollapsingProperties.cs
- Transactions.cs
- ChangeBlockUndoRecord.cs
- Keyboard.cs
- GroupDescription.cs
- HitTestWithGeometryDrawingContextWalker.cs
- LoadedOrUnloadedOperation.cs
- RequestContextBase.cs
- DataControlFieldTypeEditor.cs
- AttachmentCollection.cs
- ToolStripPanel.cs
- SqlServer2KCompatibilityCheck.cs
- HttpApplicationStateBase.cs
- EntityTypeBase.cs
- PnrpPeerResolverElement.cs
- FormsIdentity.cs
- _BasicClient.cs
- XAMLParseException.cs
- RankException.cs
- ViewStateException.cs
- DataGridLinkButton.cs
- XMLDiffLoader.cs
- OutputCacheSettings.cs
- TextTrailingWordEllipsis.cs
- Table.cs
- ControlDesignerState.cs
- OdbcUtils.cs
- AuthenticationSection.cs
- EventSourceCreationData.cs
- RepeaterItemEventArgs.cs
- ListenUriMode.cs