Пример #1
0
 public IAbstractBinding BuildBinding(BindingParserOptions bindingOptions, DothtmlBindingNode node, IDataContextStack dataContext, Exception parsingError, ITypeDescriptor resultType, object customData)
 {
     return new ResolvedBinding()
     {
         BindingType = bindingOptions.BindingType,
         Value = node.Value,
         Expression = (Expression)customData,
         DataContextTypeStack = (DataContextStack)dataContext,
         ParsingError = parsingError,
         BindingNode = node,
         ResultType = resultType
     };
 }
Пример #2
0
        /// <summary>
        /// Reads the binding.
        /// </summary>
        private DothtmlBindingNode ReadBinding()
        {
            var startIndex = CurrentIndex;
            var binding    = new DothtmlBindingNode();

            Assert(DothtmlTokenType.OpenBinding);
            binding.StartToken = Read();

            binding.NameNode = ReadName(true, true, DothtmlTokenType.Text);

            Assert(DothtmlTokenType.Colon);
            binding.SeparatorToken = Read();

            binding.ValueNode = ReadTextValue(true, true, DothtmlTokenType.Text);

            Assert(DothtmlTokenType.CloseBinding);
            binding.EndToken = Read();

            binding.Tokens.Add(GetTokensFrom(startIndex));
            return(binding);
        }
Пример #3
0
        protected override IAbstractBinding CompileBinding(DothtmlBindingNode node, BindingParserOptions bindingOptions, IDataContextStack context)
        {
            Expression expression = null;
            Exception parsingError = null;
            ITypeDescriptor resultType = null;

            if (context == null)
            {
                parsingError = new DotvvmCompilationException("The DataContext couldn't be evaluated because of the errors above.", node.Tokens);
            }
            else
            {
                try
                {
                    expression = bindingExpressionBuilder.Parse(node.Value, (DataContextStack)context, bindingOptions);
                    resultType = new ResolvedTypeDescriptor(expression.Type);
                }
                catch (Exception exception)
                {
                    parsingError = exception;
                }
            }
            return treeBuilder.BuildBinding(bindingOptions, node, context, parsingError, resultType, expression);
        }
Пример #4
0
 public void Visit(DothtmlBindingNode binding)
 {
     LastFoundNode = binding;
 }
Пример #5
0
 public DothtmlValueBindingNode(DothtmlBindingNode bindingNode, IReadOnlyList <DothtmlToken> valueTokens)
 {
     BindingNode = bindingNode;
     ValueTokens = valueTokens;
 }
Пример #6
0
 public void Visit(DothtmlBindingNode binding)
 {
     LastFoundNode = binding;
 }