コード例 #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);
 }
コード例 #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;
        }
コード例 #3
0
ファイル: StylingVisitor.cs プロジェクト: darilek/dotvvm
 public override void VisitControl(ResolvedControl control)
 {
     Matcher.PushControl(control);
     foreach (var style in Matcher.GetMatchingStyles())
     {
         style.ApplyStyle(control);
     }
     base.VisitControl(control);
     Matcher.PopControl();
 }
コード例 #4
0
        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;
        }
コード例 #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);
             }
         }
     }
 }
コード例 #6
0
 public void ApplyStyle(ResolvedControl control)
 {
     @this.ApplyStyle(control);
 }
コード例 #7
0
 public void AddChild(ResolvedControl child)
 {
     Content.Add(child);
     child.Parent = this;
 }
コード例 #8
0
 public virtual void VisitControl(ResolvedControl control)
 {
     DefaultVisit(control);
 }
コード例 #9
0
ファイル: ResolvedContentNode.cs プロジェクト: darilek/dotvvm
 public void AddChild(ResolvedControl child)
 {
     Content.Add(child);
     child.Parent = this;
 }
コード例 #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;
        }
コード例 #11
0
 public ResolvedPropertyControl(DotvvmProperty property, ResolvedControl control) : base(property)
 {
     Control        = control;
     control.Parent = this;
 }
コード例 #12
0
ファイル: StyleMatcher.cs プロジェクト: darilek/dotvvm
 public void PushControl(ResolvedControl control)
 {
     Context = new StyleMatchContext() { Control = control, Parent = Context };
 }
コード例 #13
0
 public override void VisitControl(ResolvedControl control)
 {
     var err = validator.Validate(control);
     Errors.AddRange(err);
     base.VisitControl(control);
 }
コード例 #14
0
 public ResolvedPropertyControl(DotvvmProperty property, ResolvedControl control) : base(property)
 {
     Control = control;
     control.Parent = this;
 }
コード例 #15
0
ファイル: Button.cs プロジェクト: darilek/dotvvm
 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);
 }