Exemplo n.º 1
0
        public override Node Evaluate(Env env)
        {
            if(Rules != null)
            Rules = new List<Node>(Rules.Select(r => r.Evaluate(env)));
              else
            Value = Value.Evaluate(env);

              return this;
        }
Exemplo n.º 2
0
    protected override Node Eval(Number number, Node[] args)
    {
      if (number.Unit == "%")
        return number;

      if (string.IsNullOrEmpty(number.Unit))
        return new Number(number.Value * 100, "%");

      throw new ParsingException(string.Format("Expected unitless number in function 'percentage', found {0}", number.ToCSS(null)));
    }
Exemplo n.º 3
0
        // In an operation between two Dimensions,
        // we default to the first Number's unit,
        // so `1px + 2em` will yield `3px`.
        // In the future, we could implement some unit
        // conversions such that `100cm + 10mm` would yield
        // `101cm`.
        public Node Operate(string op, Node other)
        {
            var dim = (Number) other;

              var unit = Unit;
              var otherUnit = dim.Unit;

              if (unit == otherUnit && op == "/")
            unit = "";

              else if (string.IsNullOrEmpty(unit))
            unit = otherUnit;

              else if(!string.IsNullOrEmpty(otherUnit))
              {
            // convert units
              }

              return new Number(Operation.Operate(op, Value, dim.Value), unit);
        }
Exemplo n.º 4
0
        public override Node Evaluate(Env env)
        {
            if (Evaluated != null)
            return Evaluated;

              var args = Arguments.Select(a => a.Evaluate(env));

              if (env != null)
              {
            var function = env.GetFunction(Name);

            if (function != null)
            {
              function.Name = Name;
              Evaluated = function.Call(args);
              return Evaluated;
            }
              }

              Evaluated = new TextNode(Name + "(" + Arguments.Select(a => a.Evaluate(env).ToCSS()).JoinStrings(", ") + ")");
              return Evaluated;
        }
Exemplo n.º 5
0
 public Alpha(Node value)
 {
     Value = value;
 }
Exemplo n.º 6
0
        public override Node Evaluate(Env env)
        {
            Value = Value.Evaluate(env);

              return this;
        }
Exemplo n.º 7
0
 public Shorthand(Node first, Node second)
 {
     First = first;
       Second = second;
 }
Exemplo n.º 8
0
 public Operation(string op, Node first, Node second)
 {
   First = first;
   Second = second;
   Operator = op.Trim();
 }
Exemplo n.º 9
0
 public Alpha Alpha(Node value)
 {
     return new Alpha(value);
 }
Exemplo n.º 10
0
 public Directive(string name, Node value)
 {
     Name = name;
       Value = value;
 }
Exemplo n.º 11
0
 public Url Url(Node value)
 {
     return new Url(value);
 }
Exemplo n.º 12
0
 protected abstract Node Eval(Number number, Node[] args);
Exemplo n.º 13
0
    public Node Operate(string op, Node other)
    {
      var otherColor = other as Color;

      if (otherColor == null)
        otherColor = ((IOperable)other).ToColor();

      var result = new double[3];
      for (var c = 0; c < 3; c++)
      {
        result[c] = Operation.Operate(op, RGB[c], otherColor.RGB[c]);
      }
      return new Color(result);
    }
Exemplo n.º 14
0
 public Rule(string name, Node value)
 {
   Name = name;
   Value = value;
   Variable = name != null ? name[0] == '@' : false;
 }
Exemplo n.º 15
0
 public Rule Rule(string name, Node value)
 {
     return new Rule(name, value);
 }
Exemplo n.º 16
0
 public Operation Operation(string operation, Node left, Node right)
 {
     return new Operation(operation, left, right);
 }
Exemplo n.º 17
0
 public Directive Directive(string name, Node value)
 {
     return new Directive(name, value);
 }
Exemplo n.º 18
0
 public Value Value(IEnumerable<Node> values, Node important)
 {
     return new Value(values, important);
 }
Exemplo n.º 19
0
 public Url(Node value)
 {
   Value = value;
 }
Exemplo n.º 20
0
 public Value(IEnumerable<Node> values, Node important)
 {
     Values = new NodeList(values);
       Important = important;
 }
Exemplo n.º 21
0
 public Shorthand Shorthand(Node first, Node second)
 {
     return new Shorthand(first, second);
 }
Exemplo n.º 22
0
 protected override Node Eval(Number number, Node[] args)
 {
   return new Number(Math.Floor(number.Value), number.Unit);
 }
Exemplo n.º 23
0
 public Value Value(NodeList values, Node important)
 {
   return new Value(values, important);
 }