예제 #1
0
        private ResolvedBinding ProcessBinding(DothtmlBindingNode node, DataContextStack context)
        {
            var        value          = node.Value;
            var        bindingOptions = controlResolver.ResolveBinding(node.Name);
            Expression expression     = null;
            Exception  parsingError   = null;

            try
            {
                expression = bindingParser.Parse(value, context, bindingOptions);
            }
            catch (Exception exception)
            {
                parsingError = exception;
            }
            return(new ResolvedBinding()
            {
                BindingType = bindingOptions.BindingType,
                Value = node.Value,
                Expression = expression,
                DataContextTypeStack = context,
                ParsingError = parsingError,
                BindingNode = node
            });
        }
예제 #2
0
 protected override IAbstractBinding CompileBinding(DothtmlBindingNode node, BindingParserOptions bindingOptions, IDataContextStack context, IPropertyDescriptor property)
 {
     if (context == null)
     {
         node.AddError("The DataContext couldn't be evaluated because of the errors above.");
     }
     return(treeBuilder.BuildBinding(bindingOptions, context, node, property));
 }
예제 #3
0
        /// <summary>
        /// Processes the binding node.
        /// </summary>
        public IAbstractBinding ProcessBinding(DothtmlBindingNode node, IDataContextStack context, IPropertyDescriptor property)
        {
            var bindingOptions = controlResolver.ResolveBinding(node.Name);

            if (bindingOptions == null)
            {
                node.NameNode.AddError($"Binding {node.Name} could not be resolved.");
                bindingOptions = controlResolver.ResolveBinding("value"); // just try it as with value binding
            }

            if (context != null && context.NamespaceImports.Count > 0)
            {
                bindingOptions = bindingOptions.AddImports(context.NamespaceImports);
            }

            return(CompileBinding(node, bindingOptions, context, property));
        }
예제 #4
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, context, node, resultType, parsingError, expression));
        }
예제 #5
0
 /// <summary>
 /// Compiles the binding.
 /// </summary>
 protected abstract IAbstractBinding CompileBinding(DothtmlBindingNode node, BindingParserOptions bindingOptions, IDataContextStack context, IPropertyDescriptor property);
예제 #6
0
 public IAbstractBinding BuildBinding(BindingParserOptions bindingOptions, IDataContextStack dataContext, DothtmlBindingNode node, IPropertyDescriptor property)
 {
     return(new ResolvedBinding(bindingService, bindingOptions, (DataContextStack)dataContext, node.Value, property: property as DotvvmProperty)
     {
         DothtmlNode = node,
     });
 }
예제 #7
0
 /// <summary>
 /// Compiles the binding.
 /// </summary>
 protected abstract IAbstractBinding CompileBinding(DothtmlBindingNode node, BindingParserOptions bindingOptions, IDataContextStack context);
예제 #8
0
 public void Visit(DothtmlBindingNode binding)
 {
     ResolveFromParent(binding);
 }
예제 #9
0
 public void Visit(DothtmlBindingNode binding)
 {
     ResolveFromParent(binding);
 }
예제 #10
0
 public IAbstractBinding BuildBinding(BindingParserOptions bindingOptions, IDataContextStack dataContext, DothtmlBindingNode node, ITypeDescriptor resultType = null, Exception parsingError = null, object customData = null)
 {
     return(new ResolvedBinding()
     {
         BindingType = bindingOptions.BindingType,
         Value = node.Value,
         Expression = (Expression)customData,
         DataContextTypeStack = (DataContextStack)dataContext,
         ParsingError = parsingError,
         DothtmlNode = node,
         ResultType = resultType
     });
 }