本文整理汇总了C#中System.Html.Element.QuerySelectorAll方法的典型用法代码示例。如果您正苦于以下问题:C# Element.QuerySelectorAll方法的具体用法?C# Element.QuerySelectorAll怎么用?C# Element.QuerySelectorAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Html.Element
的用法示例。
在下文中一共展示了Element.QuerySelectorAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisposeBehaviors
/// <summary>
/// Disposes and detaches behaviors attached to the specified element and optionally
/// to contained elements.
/// </summary>
/// <param name="element">The element to detach behaviors from.</param>
/// <param name="recursive">Whether to recursively detach behaviors from contained elements.</param>
public static void DisposeBehaviors(Element element, bool recursive)
{
Debug.Assert(element != null);
// TODO: Fix Script.Web
if ((bool)Type.InvokeMethod(element, "hasAttribute", Behavior.BehaviorsAttribute)) {
DetachBehaviors(element);
}
if (recursive) {
ElementCollection elements = element.QuerySelectorAll(Behavior.BehaviorsSelector);
int matchingElements = elements.Length;
if (matchingElements != 0) {
for (int i = 0; i < matchingElements; i++) {
DetachBehaviors(elements[i]);
}
}
}
}
示例2: DeactivateFragment
/// <summary>
/// Deactivates the specified element and its children by disposing any
/// behaviors or binding instances attached to the elements.
/// </summary>
/// <param name="element">The element to deactivate.</param>
/// <param name="contentOnly">Whether the element should be deactivated, or only its contained content.</param>
public void DeactivateFragment(Element element, bool contentOnly)
{
Debug.Assert(element != null);
// Detach behaviors associated with the element and the contained elements.
if ((contentOnly == false) && element.HasAttribute(Application.BehaviorsAttribute)) {
DetachBehaviors(element);
}
ElementCollection elements = element.QuerySelectorAll(Application.BehaviorsSelector);
int matchingElements = elements.Length;
if (matchingElements != 0) {
for (int i = 0; i < matchingElements; i++) {
DetachBehaviors(elements[i]);
}
}
}
示例3: SetupBehaviors
/// <summary>
/// Attaches behaviors associated declaratively with the specified element and optionally
/// to contained elements.
/// </summary>
/// <param name="element">The element to attach behaviors to.</param>
/// <param name="recursive">Whether to recursively attach behaviors from contained elements.</param>
public static void SetupBehaviors(Element element, bool recursive)
{
Debug.Assert(element != null);
if (element.HasAttribute(Behavior.BehaviorsAttribute)) {
AttachBehaviors(element);
}
if (recursive) {
ElementCollection elements = element.QuerySelectorAll(Behavior.BehaviorsSelector);
int matchingElements = elements.Length;
if (matchingElements != 0) {
for (int i = 0; i < matchingElements; i++) {
AttachBehaviors(elements[i]);
}
}
}
}
示例4: ActivateFragment
public void ActivateFragment(Element element, bool contentOnly, object model)
{
Debug.Assert(element != null);
if (element == Document.Body) {
// Perform app-level activation (tied to body initialization)
// Setup top-level services specified declaratively.
SetupServices();
// Create the model declaratively associated with the application.
if (model == null) {
string modelTypeName = (string)Document.Body.GetAttribute(ModelTypeAttribute);
if (String.IsNullOrEmpty(modelTypeName) == false) {
Type modelType = Type.GetType(modelTypeName);
Debug.Assert(modelType != null, "Could not resolve model '" + modelTypeName + "'");
model = GetObject(modelType);
IInitializable initializableModel = model as IInitializable;
if (initializableModel != null) {
Dictionary<string, object> modelData = OptionsParser.GetOptions(element, "model");
initializableModel.BeginInitialization(modelData);
initializableModel.EndInitialization();
}
}
}
_model = model;
}
// Create expressions and bindings associated with the specified elements and
// the contained elements. Do this first, as this allows behaviors to look at
// values set as a result of bindings when they are attached.
if ((contentOnly == false) && element.HasAttribute(Application.BindingsAttribute)) {
SetupBindings(element, model);
}
ElementCollection boundElements = element.QuerySelectorAll(Application.BindingsSelector);
for (int i = 0, boundElementCount = boundElements.Length; i < boundElementCount; i++) {
SetupBindings(boundElements[i], model);
}
// Attach behaviors associated declaratively with the specified element and the
// contained elements.
if ((contentOnly == false) && element.HasAttribute(Application.BehaviorsAttribute)) {
AttachBehaviors(element);
}
ElementCollection extendedElements = element.QuerySelectorAll(Application.BehaviorsSelector);
for (int i = 0, extendedElementCount = extendedElements.Length; i < extendedElementCount; i++) {
AttachBehaviors(extendedElements[i]);
}
}