public StringSegment ParseNextToken(StringSegment literal, out object value, out JsBinding binding)
 {
     try
     {
         return(literal.ParseNextToken(out value, out binding));
     }
     catch (ArgumentException e)
     {
         throw new Exception($"Invalid literal: {literal} in '{OriginalText}'", e);
     }
 }
Beispiel #2
0
 public static JsToken ToToken(this object value, JsBinding binding)
 {
     if (binding != null)
     {
         return(binding);
     }
     if (value is JsToken t)
     {
         return(t);
     }
     return(new JsConstant(value));
 }
        public PageVariableFragment(StringSegment originalText, object initialValue, JsBinding initialBinding, List <JsExpression> filterCommands)
        {
            OriginalText      = originalText;
            InitialValue      = initialValue;
            FilterExpressions = filterCommands?.ToArray() ?? TypeConstants <JsExpression> .EmptyArray;

            if (initialBinding is JsExpression initialExpr)
            {
                InitialExpression = initialExpr;
            }
            else if (initialBinding != null)
            {
                Binding       = initialBinding.Binding;
                BindingString = Binding.Value;
            }
        }
Beispiel #4
0
 public bool MatchesBinding(JsBinding binding) => binding.Binding.HasValue && (binding.Binding.Equals(Keyword) || binding.Binding.Equals(Syntax));