本文整理匯總了C#中System.Xml.Linq.XNode.Interface方法的典型用法代碼示例。如果您正苦於以下問題:C# XNode.Interface方法的具體用法?C# XNode.Interface怎麽用?C# XNode.Interface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.Linq.XNode
的用法示例。
在下文中一共展示了XNode.Interface方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DispatchEvent
/// <summary>
/// Dispatches the given event against the given node.
/// </summary>
/// <param name="node"></param>
/// <param name="eventType"></param>
void DispatchEvent(XNode node, string eventType)
{
Contract.Requires<ArgumentNullException>(node != null);
Contract.Requires<ArgumentNullException>(node.Document != null);
Contract.Requires<ArgumentNullException>(eventType != null);
node.Interface<EventTarget>().Dispatch(CreateEvent(node, eventType));
}
示例2: InvokeListeners
/// <summary>
/// Invokes the applicable listeners for this node.
/// </summary>
/// <param name="node"></param>
/// <param name="evt"></param>
void InvokeListeners(XNode node, Event evt)
{
Contract.Requires<ArgumentNullException>(node != null);
Contract.Requires<ArgumentNullException>(evt != null);
// Initialize event's currentTarget attribute to the object for which these steps are run.
evt.currentTarget = node;
// invoke registered listeners
foreach (var registration in node.Interface<EventTarget>().state.registrations)
{
// If event's stop immediate propagation flag is set, terminate the invoke algorithm.
if (evt.stopImmediatePropagation)
return;
// If event's type attribute value is not listener's type, terminate these substeps (and run them for
// the next event listener).
if (evt.type != registration.EventType)
continue;
// If event's eventPhase attribute value is CAPTURING_PHASE and listener's capture is false, terminate
// these substeps (and run them for the next event listener).
if (evt.eventPhase == EventPhase.Capturing && registration.Capture == false)
continue;
// If event's eventPhase attribute value is BUBBLING_PHASE and listener's capture is true, terminate
// these substeps (and run them for the next event listener).
if (evt.eventPhase == EventPhase.Bubbling && registration.Capture == true)
continue;
// Call listener's callback's handleEvent, with the event passed to this algorithm as the first
// argument and event's currentTarget attribute value as callback this value.
invoker.Invoke(() =>
registration.Listener.HandleEvent(evt));
}
// invoke listeners available directly as interfaces
foreach (var listener in node.Interfaces<IEventListener>())
{
// If event's stop immediate propagation flag is set, terminate the invoke algorithm.
if (evt.stopImmediatePropagation)
return;
invoker.Invoke(() =>
listener.HandleEvent(evt));
}
}