Example #1
0
 public override void VisitControl(ResolvedControl control)
 {
     if (control.DothtmlNode.HasNodeErrors)
     {
         throw new DotvvmCompilationException(string.Join("\r\n", control.DothtmlNode.NodeErrors), control.DothtmlNode.Tokens);
     }
     base.VisitControl(control);
 }
Example #2
0
        /// <summary>
        /// Processes the node.
        /// </summary>
        public override void VisitControl(ResolvedControl node)
        {
            var parentName = controlName;
            controlName = CreateControl(node);

            base.VisitControl(node);

            emitter.EmitAddCollectionItem(parentName, controlName);
            controlName = parentName;
        }
Example #3
0
 public override void VisitControl(ResolvedControl control)
 {
     Matcher.PushControl(control);
     foreach (var style in Matcher.GetMatchingStyles())
     {
         style.ApplyStyle(control);
     }
     base.VisitControl(control);
     Matcher.PopControl();
 }
        public override void VisitControl(ResolvedControl control)
        {
            var position = control.DothtmlNode.StartPosition;
            var returnType = CurrentType;
            if (CurrentType != control.DataContextTypeStack)
            {
                CurrentType = control.DataContextTypeStack;
                Result.Controls.Add(position, new ControlCompilationInfo
                {
                    DataContext = control.DataContextTypeStack.DataContextType.ToString()
                });
            }

            base.VisitControl(control);
            CurrentType = returnType;
        }
Example #5
0
 protected virtual void ApplyStyle(ResolvedControl control)
 {
     if(SetHtmlAttributes != null)
     {
         foreach (var attr in SetHtmlAttributes)
         {
             if(control.HtmlAttributes == null || !control.HtmlAttributes.ContainsKey(attr.Key) || attr.Value.append)
             {
                 control.SetHtmlAttribute(attr.Key, attr.Value.value);
             }
         }
     }
     if(SetProperties != null)
     {
         foreach (var prop in SetProperties)
         {
             if(!control.Properties.ContainsKey(prop.Key))
             {
                 control.Properties.Add(prop.Key, prop.Value);
             }
         }
     }
 }
Example #6
0
 public void ApplyStyle(ResolvedControl control)
 {
     @this.ApplyStyle(control);
 }
Example #7
0
 public void AddChild(ResolvedControl child)
 {
     Content.Add(child);
     child.Parent = this;
 }
Example #8
0
 public virtual void VisitControl(ResolvedControl control)
 {
     DefaultVisit(control);
 }
Example #9
0
 public void AddChild(ResolvedControl child)
 {
     Content.Add(child);
     child.Parent = this;
 }
Example #10
0
        /// <summary>
        /// Processes the HTML element that represents a new object.
        /// </summary>
        protected string CreateControl(ResolvedControl control)
        {
            string name;

            if (control.Metadata.ControlBuilderType == null)
            {
                // compiled control
                name = emitter.EmitCreateObject(control.Metadata.Type, control.ConstructorParameters);
            }
            else
            {
                // markup control
                name = emitter.EmitInvokeControlBuilder(control.Metadata.Type, control.Metadata.VirtualPath);
            }
            // set unique id
            emitter.EmitSetAttachedProperty(name, Internal.UniqueIDProperty, name);

            if (control.DothtmlNode != null && control.DothtmlNode.Tokens.Count > 0)
            {
                // set line number
                emitter.EmitSetAttachedProperty(name, Internal.MarkupLineNumberProperty, control.DothtmlNode.Tokens.First().LineNumber);
            }

            if (control.HtmlAttributes != null && control.Metadata.HasHtmlAttributesCollection)
            {
                ProcessHtmlAttributes(name, control.HtmlAttributes, control.DataContextTypeStack);
            }
            return name;
        }
 public ResolvedPropertyControl(DotvvmProperty property, ResolvedControl control) : base(property)
 {
     Control        = control;
     control.Parent = this;
 }
Example #12
0
 public void PushControl(ResolvedControl control)
 {
     Context = new StyleMatchContext() { Control = control, Parent = Context };
 }
 public override void VisitControl(ResolvedControl control)
 {
     var err = validator.Validate(control);
     Errors.AddRange(err);
     base.VisitControl(control);
 }
Example #14
0
 public ResolvedPropertyControl(DotvvmProperty property, ResolvedControl control) : base(property)
 {
     Control = control;
     control.Parent = this;
 }
Example #15
0
 public static IEnumerable<ControlUsageError> ValidateUsage(ResolvedControl control)
 {
     if(control.Properties.ContainsKey(TextProperty) && control.Content.Any(n => n.DothtmlNode.IsNotEmpty()))
     {
         yield return new ControlUsageError("Text property and inner content of the <dot:Button> control cannot be set at the same time!", control.DothtmlNode);
     }
     //ResolvedPropertySetter buttonType;
     //bool allowcontent = false;
     //if(control.Properties.TryGetValue(ButtonTagNameProperty, out buttonType))
     //{
     //    allowcontent = ButtonTagName.button.Equals((buttonType as ResolvedPropertyValue)?.Value);
     //}
     //if (!allowcontent && control.Content.Any(n => n.DothtmlNode.IsNotEmpty())) yield return new ControlUsageError("The <dot:Button> control cannot have inner HTML connect unless the 'ButtonTagName' property is set to 'button'!", control.DothtmlNode);
 }