/// <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);
        }
Exemple #2
0
        /// <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);
                }
            }
        }
Exemple #3
0
        /// <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);
                }
            }
        }
Exemple #4
0
        public override string ToString()
        {
            if (_selectorString == null)
            {
                _selectorString = _parent.ToString() + " /template/ ";
            }

            return(_selectorString);
        }
Exemple #5
0
 /// <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");
     }
 }
Exemple #6
0
        /// <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);
                }
            }
        }
Exemple #7
0
        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());
        }
Exemple #9
0
 /// <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());
 }