Пример #1
0
		public void LoadControl(ServerControlNode controlNode, WebFormContainer container, string prefix=null)
		{
			var prependingTagNames = new string[] 
			{
				"asp:panel"
			};
			string newPrefix = prefix ?? string.Empty;
			if (controlNode.Attributes.ContainsKey("id"))
			{
				var controlItem = new WebFormServerControl
				{
					TagName = controlNode.TagName,
					ControlID = controlNode.Attributes["id"],
					Prefix = prefix
				};
				container.Controls.Add(controlItem);
				if (prependingTagNames.Contains(controlItem.TagName, StringComparer.CurrentCultureIgnoreCase))
				{
					newPrefix += controlItem.ControlID + "_";
				}
			}
			var childControlNodeList = controlNode.Children.Where(i=>i is ServerControlNode);
			foreach(ServerControlNode childControlNode in childControlNodeList)
			{
				this.LoadControl(childControlNode, container, newPrefix);
			}
		}
Пример #2
0
        private IWebFormsNode ServerControlNodeBuilder(Match match)
        {
            var node = new ServerControlNode();

            attributesReader.ReadAttributes(match, node.Attributes);

            if (match.Groups["tagname"].Success)
            {
                node.TagName = match.Groups["tagname"].Captures[0].Value;
            }

            if (match.Groups["attributes"].Success)
            {
                var attributeRegex = new Regex(
                    @"((?<attrname>\w[-\w:]*)(\s*=\s*\""(?<attrval>[^\""]*)\""|\s*=\s*'(?<attrval>[^']*)'|\s*=\s*(?<attrval><%#.*?%>)|\s*=\s*(?<attrval>[^\s=/>]*)|(?<attrval>\s*?)))",
                    RegexOptions.Singleline | RegexOptions.Multiline);

                var attributeMatch = attributeRegex.Match(match.Groups["attributes"].Value);
                while (attributeMatch.Success)
                {
                    node.Attributes[attributeMatch.Groups["attrname"].Value] = attributeMatch.Groups["attrval"].Value;
                    attributeMatch = attributeMatch.NextMatch();
                }
            }

            return(node);
        }
        private IWebFormsNode ServerControlNodeBuilder(Match match)
        {
            var node = new ServerControlNode();
            attributesReader.ReadAttributes(match, node.Attributes);

            if (match.Groups["tagname"].Success)
            {
                node.TagName = match.Groups["tagname"].Captures[0].Value;
            }

            if (match.Groups["attributes"].Success)
            {
                var attributeRegex = new Regex(
                    @"((?<attrname>\w[-\w:]*)(\s*=\s*\""(?<attrval>[^\""]*)\""|\s*=\s*'(?<attrval>[^']*)'|\s*=\s*(?<attrval><%#.*?%>)|\s*=\s*(?<attrval>[^\s=/>]*)|(?<attrval>\s*?)))",
                    RegexOptions.Singleline | RegexOptions.Multiline);

                var attributeMatch = attributeRegex.Match(match.Groups["attributes"].Value);
                while (attributeMatch.Success)
                {
                    node.Attributes[attributeMatch.Groups["attrname"].Value] = attributeMatch.Groups["attrval"].Value;
                    attributeMatch = attributeMatch.NextMatch();
                }
            }

            return node;
        }