Exemplo n.º 1
0
        public TermNode(string unaryOperator, string numberBasedValue, string stringBasedValue,
                        string hexColor, FunctionNode functionNode, ReadOnlyCollection <ImportantCommentNode> importantComments, string replacementTokenBasedValue = null)
        {
            // Validity Checks
            // Besides the optional unary_operator, only one value can exist for the remaing arguments the rest need to be null
            var isArgumentPopulated = false;
            var hasError            = false;

            // Check for: [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* | TIME S* | FREQ S* ]
            if (!string.IsNullOrWhiteSpace(numberBasedValue))
            {
                isArgumentPopulated = true;
            }

            // check for: STRING | IDENT | URI
            if (!string.IsNullOrWhiteSpace(stringBasedValue))
            {
                if (isArgumentPopulated)
                {
                    hasError = true;
                }
                else
                {
                    isArgumentPopulated = true;
                }
            }

            // check for: hexcolor
            if (!string.IsNullOrWhiteSpace(hexColor))
            {
                if (isArgumentPopulated)
                {
                    hasError = true;
                }
                else
                {
                    isArgumentPopulated = true;
                }
            }

            // functionNode
            if (functionNode != null)
            {
                if (isArgumentPopulated)
                {
                    hasError = true;
                }
            }

            if (hasError)
            {
                throw new AstException(CssStrings.ExpectedSingleValue);
            }


            // Member Initialization
            this.UnaryOperator              = unaryOperator;
            this.NumberBasedValue           = numberBasedValue;
            this.StringBasedValue           = stringBasedValue;
            this.Hexcolor                   = hexColor;
            this.FunctionNode               = functionNode;
            this.ImportantComments          = importantComments ?? (new List <ImportantCommentNode>()).AsReadOnly();
            this.IsBinary                   = false;
            this.ReplacementTokenBasedValue = replacementTokenBasedValue;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Determine if two Function nodes are equal
 /// </summary>
 /// <param name="functionNode"> Another Function node to Compare.</param>
 /// <returns> Equal or not. </returns>
 public bool Equals(FunctionNode functionNode)
 {
     return(this.FunctionName == functionNode.FunctionName &&
            this.ExprNode.Equals(functionNode.ExprNode));
 }