/// <inheritdoc/> public override string ToString() { if (_selectorString == null) { var builder = new StringBuilder(); if (_previous != null) { builder.Append(_previous.ToString()); } builder.Append('['); if (_property.IsAttached) { builder.Append(_property.OwnerType.Name); builder.Append('.'); } builder.Append(_property.Name); builder.Append('='); builder.Append(_value); builder.Append(']'); _selectorString = builder.ToString(); } return(_selectorString); }
/// <summary> /// Attaches the style to a control if the style's selector matches. /// </summary> /// <param name="control">The control to attach to.</param> /// <param name="container"> /// The control that contains this style. May be null. /// </param> public void Attach(IStyleable control, IStyleHost container) { if (Selector != null) { var description = "Style " + Selector.ToString(); var match = Selector.Match(control); if (match.ImmediateResult != false) { var activator = (match.ObservableResult ?? True) .TakeUntil(control.StyleDetach); foreach (var setter in Setters) { setter.Apply(this, control, activator); } } } else if (control == container) { foreach (var setter in Setters) { setter.Apply(this, control, null); } } }
/// <summary> /// Attaches the style to a control if the style's selector matches. /// </summary> /// <param name="control">The control to attach to.</param> /// <param name="container"> /// The control that contains this style. May be null. /// </param> public void Attach(IStyleable control, IStyleHost container) { if (Selector != null) { var description = "Style " + Selector.ToString(); var match = Selector.Match(control); if (match.ImmediateResult != false) { var subs = GetSubscriptions(control); foreach (var setter in Setters) { var sub = setter.Apply(this, control, match.ObservableResult); subs.Add(sub); } } } else if (control == container) { var subs = GetSubscriptions(control); foreach (var setter in Setters) { var sub = setter.Apply(this, control, null); subs.Add(sub); } } }
public override string ToString() { if (_selectorString == null) { _selectorString = _parent.ToString() + " /template/ "; } return(_selectorString); }
/// <summary> /// Returns a string representation of the style. /// </summary> /// <returns>A string representation of the style.</returns> public override string ToString() { if (Selector != null) { return("Style: " + Selector.ToString()); } else { return("Style"); } }
/// <summary> /// Attaches the style to a control if the style's selector matches. /// </summary> /// <param name="control">The control to attach to.</param> public void Attach(IStyleable control) { var description = "Style " + Selector.ToString(); var match = Selector.Match(control); if (match.ImmediateResult != false) { foreach (var setter in Setters) { setter.Apply(this, control, match.ObservableResult); } } }
private string BuildSelectorString() { var builder = new StringBuilder(); if (_previous != null) { builder.Append(_previous.ToString()); } if (TargetType != null) { if (IsConcreteType) { builder.Append(TargetType.Name); } else { builder.Append(":is("); builder.Append(TargetType.Name); builder.Append(")"); } } if (Name != null) { builder.Append('#'); builder.Append(Name); } if (_classes.IsValueCreated && _classes.Value.Count > 0) { foreach (var c in Classes) { if (!c.StartsWith(":")) { builder.Append('.'); } builder.Append(c); } } return(builder.ToString()); }
public void PesudoClass_Selector_Should_Have_Correct_String_Representation() { var target = new Selector().Class(":foo"); Assert.Equal(":foo", target.ToString()); }
/// <summary> /// Returns a string representation of the style. /// </summary> /// <returns>A string representation of the style.</returns> public override string ToString() { return("Style: " + Selector.ToString()); }