Example #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);
            }
        }
Example #2
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);
			}
		}
Example #3
0
        public virtual WebFormContainer ParseString(string input, string filePath)
        {
            WebFormContainer returnValue;
            var            nodeFactory          = new WebFormsNodeFactory();
            var            codeGroupNodeFactory = new WebFormsCodeGroupFactory();
            var            nodeFilterProvider   = new WebFormsNodeFilterProvider(codeGroupNodeFactory);
            WebFormsParser telerikParser        = new WebFormsParser(nodeFactory, nodeFilterProvider);
            var            document             = telerikParser.Parse(input);

            var directiveNode = document.RootNode.Children.FirstOrDefault(i => i is DirectiveNode && !i.Attributes.ContainsKey("Register"));

            if (directiveNode == null)
            {
                throw new ArgumentException("Failed to find directive node");
            }
            returnValue = new WebFormContainer
            {
                CodeBehindFile = directiveNode.Attributes["codebehind"],
                ClassFullName  = directiveNode.Attributes["inherits"],
                FilePath       = filePath
            };
            if (directiveNode.Attributes.ContainsKey("page"))
            {
                returnValue.ContainerType = EnumWebFormContainerType.WebPage;
            }
            else if (directiveNode.Attributes.ContainsKey("master"))
            {
                returnValue.ContainerType = EnumWebFormContainerType.MasterPage;
            }
            else if (directiveNode.Attributes.ContainsKey("control"))
            {
                returnValue.ContainerType = EnumWebFormContainerType.UserControl;
            }
            else
            {
                throw new Exception("Unrecognized directive");
            }
            var controlList = document.RootNode.Children.Where(i => i is ServerControlNode);

            foreach (ServerControlNode control in controlList)
            {
                this.LoadControl(control, returnValue);
            }
            return(returnValue);
        }
		private List<SourceWebControl> LoadControls(WebFormContainer webPage, CSClass csClass)
		{
			List<SourceWebControl> returnList = new List<SourceWebControl>();
			foreach(var serverControl in webPage.Controls)
			{
				var classField = csClass.FieldList.SingleOrDefault(i=>i.FieldName == serverControl.ControlID);
				if(classField != null)
				{
					SourceWebControl sourceWebControl = new SourceWebControl
					{
						ClassFullName = classField.TypeFullName,
						FieldName = (serverControl.Prefix??string.Empty) + classField.FieldName
					};
					returnList.Add(sourceWebControl);
				}
			}
			return returnList;
		}
Example #5
0
		public virtual WebFormContainer ParseString(string input, string filePath)
		{
			WebFormContainer returnValue;
			var nodeFactory = new WebFormsNodeFactory();
			var codeGroupNodeFactory = new WebFormsCodeGroupFactory();
			var nodeFilterProvider = new WebFormsNodeFilterProvider(codeGroupNodeFactory);
			WebFormsParser telerikParser = new WebFormsParser(nodeFactory, nodeFilterProvider);
			var document = telerikParser.Parse(input);
			
			var directiveNode = document.RootNode.Children.FirstOrDefault(i=>i is DirectiveNode && !i.Attributes.ContainsKey("Register"));
			if(directiveNode == null)
			{
				throw new ArgumentException("Failed to find directive node");
			}
			returnValue = new WebFormContainer
			{
				CodeBehindFile = directiveNode.Attributes["codebehind"],
				ClassFullName = directiveNode.Attributes["inherits"],
				FilePath = filePath
			};
			if (directiveNode.Attributes.ContainsKey("page"))
			{
				returnValue.ContainerType = EnumWebFormContainerType.WebPage;
			}
			else if (directiveNode.Attributes.ContainsKey("master"))
			{
				returnValue.ContainerType = EnumWebFormContainerType.MasterPage;
			}
			else if(directiveNode.Attributes.ContainsKey("control"))
			{
				returnValue.ContainerType = EnumWebFormContainerType.UserControl;
			}
			else
			{
				throw new Exception("Unrecognized directive");
			}
			var controlList = document.RootNode.Children.Where(i=>i is ServerControlNode);
			foreach (ServerControlNode control in controlList)
			{
				this.LoadControl(control, returnValue);
			}
			return returnValue;
		}