Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormatConditionElement"/> class.
        /// </summary>
        /// <param name="name">The name of the condition.</param>
        /// <param name="isNegated"><c>true</c> if the format structure should represent a negated condition.</param>
        /// <param name="content">The content inserted based on condition evaluation.</param>
        public FormatConditionElement(string name, bool isNegated, FormatElement content)
        {
            Name      = name ?? throw new ArgumentNullException(nameof(name));
            IsNegated = isNegated;
            Content   = content ?? throw new ArgumentNullException(nameof(content));

            if (Name.Contains(" "))
            {
                throw new ArgumentException("Condition names cannot contain spaces.", nameof(name));
            }
        }
Esempio n. 2
0
 public override bool Equals(FormatElement other)
 {
     if (ReferenceEquals(other, null))
     {
         return(false);
     }
     else if (ReferenceEquals(other, this))
     {
         return(true);
     }
     else if (other is FormatConditionElement cond)
     {
         return(Equals(cond));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 3
0
 public override bool Equals(FormatElement other)
 {
     if (ReferenceEquals(other, null))
     {
         return(false);
     }
     else if (ReferenceEquals(other, this))
     {
         return(true);
     }
     else if (other is FormatTextElement text)
     {
         return(Equals(text));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 4
0
 public override bool Equals(FormatElement other)
 {
     if (ReferenceEquals(other, null))
     {
         return(false);
     }
     else if (ReferenceEquals(other, this))
     {
         return(true);
     }
     else if (other is FormatVariableElement var)
     {
         return(Equals(var));
     }
     else
     {
         return(false);
     }
 }
 public override bool Equals(FormatElement other)
 {
     if (ReferenceEquals(other, null))
     {
         return(false);
     }
     else if (ReferenceEquals(other, this))
     {
         return(true);
     }
     else if (other is FormatFunctionElement func)
     {
         return(Equals(func));
     }
     else
     {
         return(false);
     }
 }
        public TResult Visit(FormatElement format)
        {
            switch (format)
            {
            case FormatColorElement color: return(Visit(color));

            case FormatConcatenationElement concatenation: return(Visit(concatenation));

            case FormatConditionElement condition: return(Visit(condition));

            case FormatFunctionElement function: return(Visit(function));

            case FormatNoContentElement noContent: return(Visit(noContent));

            case FormatTextElement text: return(Visit(text));

            case FormatVariableElement variable: return(Visit(variable));

            default:
                throw new NotSupportedException($"The element type {format.GetType().Name} is not supported.");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FormatColorElement"/> class.
 /// </summary>
 /// <param name="color">The color applied to content. Use <see cref="AutoColor"/> to have color applied based on a variable.</param>
 /// <param name="content">The content to which color should be applied.</param>
 public FormatColorElement(string color, FormatElement content)
 {
     Color   = color?.ToLowerInvariant() ?? throw new ArgumentNullException(nameof(color));
     Content = content ?? throw new ArgumentNullException(nameof(content));
 }