Beispiel #1
0
        public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction)
        {
            if (node.NodeType != XmlNodeType.ProcessingInstruction)
            {
                return(false);
            }

            string v = node.Value.Trim();

            switch (node.Name)
            {
            case "x":
                if (v == "")
                {
                    throw ParserUtils.TemplateErrorException("Empty embedded expression");
                }
                currentRenderFunction.AddFragment(new CodeExpressionFragment(v)); return(true);

            case "c":
                if (v == "")
                {
                    throw ParserUtils.TemplateErrorException("Empty embedded code");
                }
                currentRenderFunction.AddFragment(new CodeFragment(v, 0)); return(true);

            default:  return(false);
            }
        }
Beispiel #2
0
        internal static void ProcessSwitchContent(IDocumentProcessor docProcessor, XmlNode switchNode, ITemplate template, IRenderFunction currentRenderFunction)
        {
            bool hasDefault = false;
            bool hasAny     = false;

            Utils.DoForEachChild(switchNode, delegate(XmlNode child) {
                                #if CLIENT
                if (((child.NodeType == XmlNodeType.Text || child.NodeType == XmlNodeType.CDATA) && child.Value.Trim() == "") || child.NodeType == XmlNodeType.Comment)
                {
                    return;
                }
                                #else
                if (child.NodeType == XmlNodeType.Whitespace || child.NodeType == XmlNodeType.SignificantWhitespace || child.NodeType == XmlNodeType.Comment)
                {
                    return;
                }
                                #endif

                if (child.NodeType == XmlNodeType.Element && child.Name == "case")
                {
                    XmlAttribute valueAttr = (XmlAttribute)child.Attributes.GetNamedItem("value");
                    if (valueAttr == null)
                    {
                        throw ParserUtils.TemplateErrorException("The <case> element must have the value attribute specified.");
                    }
                    currentRenderFunction.AddFragment(new CodeFragment("case " + valueAttr.Value + ": {", 1));
                }
                else if (child.NodeType == XmlNodeType.Element && child.Name == "default")
                {
                    if (hasDefault)
                    {
                        throw ParserUtils.TemplateErrorException("There can only be one <default> element inside <switch>");
                    }
                    hasDefault = true;
                    currentRenderFunction.AddFragment(new CodeFragment("default: {", 1));
                }
                else
                {
                    throw ParserUtils.TemplateErrorException("The <switch> element can only have <case> and <default> elements as children.");
                }

                hasAny = true;
                Utils.DoForEachChild(child, delegate(XmlNode grandchild) {
                    docProcessor.ProcessRecursive(grandchild, template, currentRenderFunction);
                });

                currentRenderFunction.AddFragment(new CodeFragment("break;", -1));
                currentRenderFunction.AddFragment(new CodeFragment("}", 0));
            });
            if (!hasAny)
            {
                throw ParserUtils.TemplateErrorException("The <switch> element must contain at least one <case> or <default>");
            }
        }
        internal static void AddSingleAttributeFragments(IDocumentProcessor docProcessor, string attrName, string attrValue, bool isRoot, ITemplate template, IRenderFunction fragments, GenericElementProcessorContext context)
        {
            string actualName;

            if (attrName == "actualName")
            {
                // This will translate into "name", but not with our ID prefixed. We need this because for top-level templates we want the names undisturbed to allow for a nice form submission.
                // However, for nested forms which we won't submit using the normal techniques, we need to prefix it in order to make radio buttons work reliably.
                actualName = "name";
            }
            else
            {
                actualName = attrName;
            }

            fragments.AddFragment(new LiteralFragment(" " + actualName + "=\""));
            if (attrName == "id")
            {
                if (isRoot)
                {
                    throw ParserUtils.TemplateErrorException("Can't specify an ID for the top level element.");
                }
                if (template.HasMember(attrValue))
                {
                    throw ParserUtils.TemplateErrorException("Duplicate member " + attrValue);
                }
                context.Id = attrValue;

                fragments.AddFragment(new IdFragment());
                fragments.AddFragment(new LiteralFragment("_" + attrValue));
            }
            else if (attrName.ToLowerCase() == "for" || attrName.ToLowerCase() == "name")
            {
                fragments.AddFragment(new IdFragment());
                fragments.AddFragment(new LiteralFragment("_" + attrValue));
            }
            else
            {
                IFragment f = docProcessor.ParseUntypedMarkup(attrValue);
                fragments.AddFragment(f);
                if (attrName.ToLowerCase() == "type")
                {
                    if (f is LiteralFragment)
                    {
                        context.Type = ((LiteralFragment)f).Text;
                    }
                }
                else if (isRoot && attrName.ToLowerCase() == "style")
                {
                    if (!(f is LiteralFragment) || !((LiteralFragment)f).Text.Trim().EndsWith(";"))
                    {
                        fragments.AddFragment(new LiteralFragment(";"));
                    }
                    fragments.AddFragment(new PositionFragment());
                }
            }

            fragments.AddFragment(new LiteralFragment("\""));
        }
Beispiel #4
0
        public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction)
        {
            string name = node.Name;

            if (node.NodeType == XmlNodeType.Element && name == "def-fragment")
            {
                if (isRoot)
                {
                    throw ParserUtils.TemplateErrorException("Fragment definitions must be inside the template.");
                }
                ProcessDefFragment(docProcessor, node, template);
                return(true);
            }
            else if (node.NodeType == XmlNodeType.Element && name == "call-fragment")
            {
                if (isRoot)
                {
                    throw ParserUtils.TemplateErrorException("Fragment instantiations must be inside the template.");
                }
                currentRenderFunction.AddFragment(ProcessCallFragment(docProcessor, node));
                return(true);
            }
            else
            {
                return(false);
            }
        }
		public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
			if (node.NodeType != XmlNodeType.Element)
				return false;

			GenericElementProcessorContext context = new GenericElementProcessorContext();

			currentRenderFunction.AddFragment(new LiteralFragment("<" + node.Name));
			AddAttributeFragments(docProcessor, node, isRoot, template, currentRenderFunction, context);

			if (context.Id != null) {
				string tagName = node.Name;
				if (tagName.ToLowerCase() == "input" && context.Type != null)
					tagName += "/" + context.Type;
				template.AddMember(new NamedElementMember(tagName, context.Id));
			}

			if (noContentTags.Contains(node.Name)) {
				if (Utils.GetNumChildNodes(node) > 0)
					throw ParserUtils.TemplateErrorException("The tag " + node.Name + " can not have children.");
				currentRenderFunction.AddFragment(new LiteralFragment("/>"));
			}
			else {
				currentRenderFunction.AddFragment(new LiteralFragment(">"));
				Utils.DoForEachChild(node, delegate(XmlNode child) {
					docProcessor.ProcessRecursive(child, template, currentRenderFunction);
				});
				currentRenderFunction.AddFragment(new LiteralFragment("</" + node.Name + ">"));
			}

			return true;
		}
		public virtual void SetupRepo() {
			mocks = new MockRepository();
			template = mocks.StrictMock<ITemplate>();
			docProcessor = mocks.StrictMock<IDocumentProcessor>();
			renderFunction = mocks.StrictMock<IRenderFunction>();
			fragments = new List<IFragment>();
			Expect.Call(() => renderFunction.AddFragment(null)).Do((Action<IFragment>)(f => fragments.Add(f))).IgnoreArguments().Repeat.Any();
		}
		public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
			if (node.NodeType != XmlNodeType.ProcessingInstruction)
				return false;

			string v = node.Value.Trim();
			switch (node.Name) {
				case "x":
					if (v == "")
						throw ParserUtils.TemplateErrorException("Empty embedded expression");
					currentRenderFunction.AddFragment(new CodeExpressionFragment(v)); return true;
				case "c":
					if (v == "")
						throw ParserUtils.TemplateErrorException("Empty embedded code");
					currentRenderFunction.AddFragment(new CodeFragment(v, 0)); return true;
				default:  return false;
			}
		}
Beispiel #8
0
 public virtual void SetupRepo()
 {
     mocks          = new MockRepository();
     template       = mocks.StrictMock <ITemplate>();
     docProcessor   = mocks.StrictMock <IDocumentProcessor>();
     renderFunction = mocks.StrictMock <IRenderFunction>();
     fragments      = new List <IFragment>();
     Expect.Call(() => renderFunction.AddFragment(null)).Do((Action <IFragment>)(f => fragments.Add(f))).IgnoreArguments().Repeat.Any();
 }
        public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction)
        {
            if (node.NodeType != XmlNodeType.Element)
            {
                return(false);
            }

            GenericElementProcessorContext context = new GenericElementProcessorContext();

            currentRenderFunction.AddFragment(new LiteralFragment("<" + node.Name));
            AddAttributeFragments(docProcessor, node, isRoot, template, currentRenderFunction, context);

            if (context.Id != null)
            {
                string tagName = node.Name;
                if (tagName.ToLowerCase() == "input" && context.Type != null)
                {
                    tagName += "/" + context.Type;
                }
                template.AddMember(new NamedElementMember(tagName, context.Id));
            }

            if (noContentTags.Contains(node.Name))
            {
                if (Utils.GetNumChildNodes(node) > 0)
                {
                    throw ParserUtils.TemplateErrorException("The tag " + node.Name + " can not have children.");
                }
                currentRenderFunction.AddFragment(new LiteralFragment("/>"));
            }
            else
            {
                currentRenderFunction.AddFragment(new LiteralFragment(">"));
                Utils.DoForEachChild(node, delegate(XmlNode child) {
                    docProcessor.ProcessRecursive(child, template, currentRenderFunction);
                });
                currentRenderFunction.AddFragment(new LiteralFragment("</" + node.Name + ">"));
            }

            return(true);
        }
		public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
			switch (node.NodeType) {
				case XmlNodeType.CDATA:
					currentRenderFunction.AddFragment(new LiteralFragment(node.Value, true));
					return true;

				case XmlNodeType.Text:
				#if !CLIENT
					case XmlNodeType.Whitespace:
					case XmlNodeType.SignificantWhitespace:
				#endif
					currentRenderFunction.AddFragment(new LiteralFragment(NormalizeSpaces(node.Value)));
					return true;

				case XmlNodeType.Comment:
					return true;

				default:
					return false;
			}
		}
        internal static void AddAttributeFragments(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction fragments, GenericElementProcessorContext context)
        {
            bool hasStyle = false;

            Utils.DoForEachAttribute(node, delegate(XmlAttribute attr) {
                AddSingleAttributeFragments(docProcessor, attr.Name, attr.Value, isRoot, template, fragments, context);
                if (attr.Name == "style")
                {
                    hasStyle = true;
                }
            });

            if (isRoot)
            {
                fragments.AddFragment(new LiteralFragment(" id=\""));
                fragments.AddFragment(new IdFragment());
                fragments.AddFragment(new LiteralFragment("\""));
                if (!hasStyle)
                {
                    fragments.AddFragment(new LiteralFragment(" style=\""));
                    fragments.AddFragment(new PositionFragment());
                    fragments.AddFragment(new LiteralFragment("\""));
                }
            }
        }
Beispiel #12
0
        public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction)
        {
            switch (node.NodeType)
            {
            case XmlNodeType.CDATA:
                currentRenderFunction.AddFragment(new LiteralFragment(node.Value, true));
                return(true);

            case XmlNodeType.Text:
                                #if !CLIENT
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                                #endif
                currentRenderFunction.AddFragment(new LiteralFragment(NormalizeSpaces(node.Value)));
                return(true);

            case XmlNodeType.Comment:
                return(true);

            default:
                return(false);
            }
        }
		internal static void AddSingleAttributeFragments(IDocumentProcessor docProcessor, string attrName, string attrValue, bool isRoot, ITemplate template, IRenderFunction fragments, GenericElementProcessorContext context) {
			string actualName;
			if (attrName == "actualName") {
				// This will translate into "name", but not with our ID prefixed. We need this because for top-level templates we want the names undisturbed to allow for a nice form submission.
				// However, for nested forms which we won't submit using the normal techniques, we need to prefix it in order to make radio buttons work reliably.
				actualName = "name";
			}
			else
				actualName = attrName;
			
			fragments.AddFragment(new LiteralFragment(" " + actualName + "=\""));
			if (attrName == "id") {
				if (isRoot)
					throw ParserUtils.TemplateErrorException("Can't specify an ID for the top level element.");
				if (template.HasMember(attrValue))
					throw ParserUtils.TemplateErrorException("Duplicate member " + attrValue);
				context.Id = attrValue;

				fragments.AddFragment(new IdFragment());
				fragments.AddFragment(new LiteralFragment("_" + attrValue));
			}
			else if (attrName.ToLowerCase() == "for" || attrName.ToLowerCase() == "name") {
				fragments.AddFragment(new IdFragment());
				fragments.AddFragment(new LiteralFragment("_" + attrValue));
			}
			else {
				IFragment f = docProcessor.ParseUntypedMarkup(attrValue);
				fragments.AddFragment(f);
				if (attrName.ToLowerCase() == "type") {
					if (f is LiteralFragment)
						context.Type = ((LiteralFragment)f).Text;
				}
				else if (isRoot && attrName.ToLowerCase() == "style") {
					if (!(f is LiteralFragment) || !((LiteralFragment)f).Text.Trim().EndsWith(";"))
						fragments.AddFragment(new LiteralFragment(";"));
					fragments.AddFragment(new PositionFragment());
				}
			}

			fragments.AddFragment(new LiteralFragment("\""));
		}
		public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
			if (node.NodeType != XmlNodeType.Element || node.Name != "copyright")
				return false;

			if (node.ChildNodes.Count != 1 || node.ChildNodes[0].NodeType != XmlNodeType.Text)
				throw new TemplateErrorException("The copyright node must have a single text child.");

			CopyrightMember m = new CopyrightMember();
			if (template.HasMember(m.Name))
				throw new TemplateErrorException("Duplicate definition of the member " + m.Name);
			template.AddMember(m);
			
			currentRenderFunction.AddFragment(new CopyrightFragment(node.ChildNodes[0].Value));
			
			return true;
		}
		public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
			string name = node.Name;
			if (node.NodeType == XmlNodeType.Element && name == "def-fragment") {
				if (isRoot)
					throw ParserUtils.TemplateErrorException("Fragment definitions must be inside the template.");
				ProcessDefFragment(docProcessor, node, template);
				return true;
			}
			else if (node.NodeType == XmlNodeType.Element && name == "call-fragment") {
				if (isRoot)
					throw ParserUtils.TemplateErrorException("Fragment instantiations must be inside the template.");
				currentRenderFunction.AddFragment(ProcessCallFragment(docProcessor, node));
				return true;
			}
			else
				return false;
		}
Beispiel #16
0
        public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction)
        {
            if (node.NodeType != XmlNodeType.Element || node.Name != "copyright")
            {
                return(false);
            }

            if (node.ChildNodes.Count != 1 || node.ChildNodes[0].NodeType != XmlNodeType.Text)
            {
                throw new TemplateErrorException("The copyright node must have a single text child.");
            }

            CopyrightMember m = new CopyrightMember();

            if (template.HasMember(m.Name))
            {
                throw new TemplateErrorException("Duplicate definition of the member " + m.Name);
            }
            template.AddMember(m);

            currentRenderFunction.AddFragment(new CopyrightFragment(node.ChildNodes[0].Value));

            return(true);
        }
		internal static void AddAttributeFragments(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction fragments, GenericElementProcessorContext context) {
			bool hasStyle = false;
			Utils.DoForEachAttribute(node, delegate(XmlAttribute attr) {
				AddSingleAttributeFragments(docProcessor, attr.Name, attr.Value, isRoot, template, fragments, context);
				if (attr.Name == "style")
					hasStyle = true;
			});

			if (isRoot) {
				fragments.AddFragment(new LiteralFragment(" id=\""));
				fragments.AddFragment(new IdFragment());
				fragments.AddFragment(new LiteralFragment("\""));
				if (!hasStyle) {
					fragments.AddFragment(new LiteralFragment(" style=\""));
					fragments.AddFragment(new PositionFragment());
					fragments.AddFragment(new LiteralFragment("\""));
				}
			}
		}
Beispiel #18
0
        public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction)
        {
            if (node.NodeType != XmlNodeType.Element)
            {
                return(false);
            }

            if (node.Name == "case" || node.Name == "default")
            {
                throw ParserUtils.TemplateErrorException("<case> and <default> can only occur inside <switch>");
            }
            if (node.Name == "else-if" || node.Name == "else")
            {
                throw ParserUtils.TemplateErrorException("<else-if> and <else> can only occur inside <if>");
            }

            string statement = GetStatement(node);

            if (statement == null)
            {
                return(false);
            }

            if (isRoot)
            {
                throw ParserUtils.TemplateErrorException("Control flow nodes cannot be root elements.");
            }

            currentRenderFunction.AddFragment(new CodeFragment(statement + " {", 1));

            if (node.Name == "switch")
            {
                ProcessSwitchContent(docProcessor, node, template, currentRenderFunction);
            }
            else
            {
                bool hasElse = false;
                Utils.DoForEachChild(node, delegate(XmlNode child) {
                    if (node.Name == "if" && (child.NodeType == XmlNodeType.Element && (child.Name == "else-if" || child.Name == "else")))
                    {
                        if (hasElse)
                        {
                            throw ParserUtils.TemplateErrorException("There cannot be other <else-if> or <else> elements after <else>.");
                        }
                        if (Utils.GetNumChildNodes(child) > 0)
                        {
                            throw ParserUtils.TemplateErrorException("<" + child.Name + "> elements should not have children.");
                        }
                        string possibleTest;
                        if (child.Name == "else-if")
                        {
                            XmlAttribute testAttr = (XmlAttribute)child.Attributes.GetNamedItem("test");
                            if (testAttr == null)
                            {
                                throw ParserUtils.TemplateErrorException("The <else-if> elements must have the test attribute specified.");
                            }
                            possibleTest = "if (" + testAttr.Value + ") ";
                        }
                        else
                        {
                            hasElse      = true;
                            possibleTest = "";
                        }
                        currentRenderFunction.AddFragment(new CodeFragment(null, -1));
                        currentRenderFunction.AddFragment(new CodeFragment("}", 0));
                        currentRenderFunction.AddFragment(new CodeFragment("else " + possibleTest + "{", 1));
                    }
                    else
                    {
                        docProcessor.ProcessRecursive(child, template, currentRenderFunction);
                    }
                });
            }

            currentRenderFunction.AddFragment(new CodeFragment(null, -1));
            currentRenderFunction.AddFragment(new CodeFragment("}", 0));

            return(true);
        }
		public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction) {
			if (node.NodeType != XmlNodeType.Element || node.Name != "control")
				return false;
			
			if (isRoot)
				throw ParserUtils.TemplateErrorException("The root element can not be a control.");

			string id = null;
			string type = null;
			bool customInstantiate = false;
			Dictionary<string, TypedMarkupData> additionalProperties = new Dictionary<string, TypedMarkupData>();

			Utils.DoForEachAttribute(node, delegate(XmlAttribute attr) {
				if (attr.Name == "id") {
					if (!ParserUtils.IsValidUnqualifiedName(attr.Value))
						throw ParserUtils.TemplateErrorException("The id '" + attr.Value + "' is not a valid identifier.");
					id = attr.Value;
				}
				else if (attr.Name == "type") {
					if (string.IsNullOrEmpty(attr.Value))
						throw ParserUtils.TemplateErrorException("The control type '" + attr.Value + "' is invalid.");
					type = attr.Value;
				}
				else if (attr.Name == "customInstantiate") {
					string v = attr.Value.ToLowerCase();
					customInstantiate = Utils.ParseBool(v);
				}
				else {
					additionalProperties[attr.Name] = docProcessor.ParseTypedMarkup(attr.Value);
				}
			});
			
			if (customInstantiate && additionalProperties.Count > 0)
				throw ParserUtils.TemplateErrorException("There can not be any property assignments when customInstantiate is true.");

			if (type == null)
				throw ParserUtils.TemplateErrorException("The control '" + id + "' does not have a type specified.");
			if (id == null)
				id = template.GetUniqueId();
			if (template.HasMember(id))
				throw ParserUtils.TemplateErrorException("Duplicate definition of member " + id);

			var dependencies = new List<IMember>();
			int numInnerFragments = 0;
			if (Utils.GetNumChildNodes(node) > 0) {
				Utils.DoForEachChild(node, delegate(XmlNode n) {
					if (n.OuterXml.Trim() != "") {
						numInnerFragments++;
						string innerName = id + "_inner" + Utils.ToStringInvariantInt(numInnerFragments);
						if (template.HasMember(innerName))
							throw ParserUtils.TemplateErrorException("The internal name " + innerName + " is already in use.");
						IRenderFunction innerFunction = new RenderFunctionMember(innerName, "");
						template.AddMember((IMember)innerFunction);
						docProcessor.ProcessRecursive(n, template, innerFunction);
						dependencies.Add(innerFunction);
					}
				});
			}
			
			if (!template.HasMember("Container"))
				template.AddMember(new PropertyMember("Container", "IContainer", "IContainer", AccessModifier._Public, "_container", "IContainer", "IContainer", true, true, null, true));

			IMember controlMember = new InstantiatedControlMember(id, type, customInstantiate, additionalProperties, dependencies);
			template.AddMember(controlMember);

			currentRenderFunction.AddFragment(new InstantiatedControlFragment(id, customInstantiate, numInnerFragments));
			currentRenderFunction.AddDependency(controlMember);

			return true;
		}
Beispiel #20
0
        public bool TryProcess(IDocumentProcessor docProcessor, XmlNode node, bool isRoot, ITemplate template, IRenderFunction currentRenderFunction)
        {
            if (node.NodeType != XmlNodeType.Element || node.Name != "control")
            {
                return(false);
            }

            if (isRoot)
            {
                throw ParserUtils.TemplateErrorException("The root element can not be a control.");
            }

            string id   = null;
            string type = null;
            bool   customInstantiate = false;
            Dictionary <string, TypedMarkupData> additionalProperties = new Dictionary <string, TypedMarkupData>();

            Utils.DoForEachAttribute(node, delegate(XmlAttribute attr) {
                if (attr.Name == "id")
                {
                    if (!ParserUtils.IsValidUnqualifiedName(attr.Value))
                    {
                        throw ParserUtils.TemplateErrorException("The id '" + attr.Value + "' is not a valid identifier.");
                    }
                    id = attr.Value;
                }
                else if (attr.Name == "type")
                {
                    if (string.IsNullOrEmpty(attr.Value))
                    {
                        throw ParserUtils.TemplateErrorException("The control type '" + attr.Value + "' is invalid.");
                    }
                    type = attr.Value;
                }
                else if (attr.Name == "customInstantiate")
                {
                    string v          = attr.Value.ToLowerCase();
                    customInstantiate = Utils.ParseBool(v);
                }
                else
                {
                    additionalProperties[attr.Name] = docProcessor.ParseTypedMarkup(attr.Value);
                }
            });

            if (customInstantiate && additionalProperties.Count > 0)
            {
                throw ParserUtils.TemplateErrorException("There can not be any property assignments when customInstantiate is true.");
            }

            if (type == null)
            {
                throw ParserUtils.TemplateErrorException("The control '" + id + "' does not have a type specified.");
            }
            if (id == null)
            {
                id = template.GetUniqueId();
            }
            if (template.HasMember(id))
            {
                throw ParserUtils.TemplateErrorException("Duplicate definition of member " + id);
            }

            var dependencies      = new List <IMember>();
            int numInnerFragments = 0;

            if (Utils.GetNumChildNodes(node) > 0)
            {
                Utils.DoForEachChild(node, delegate(XmlNode n) {
                    if (n.OuterXml.Trim() != "")
                    {
                        numInnerFragments++;
                        string innerName = id + "_inner" + Utils.ToStringInvariantInt(numInnerFragments);
                        if (template.HasMember(innerName))
                        {
                            throw ParserUtils.TemplateErrorException("The internal name " + innerName + " is already in use.");
                        }
                        IRenderFunction innerFunction = new RenderFunctionMember(innerName, "");
                        template.AddMember((IMember)innerFunction);
                        docProcessor.ProcessRecursive(n, template, innerFunction);
                        dependencies.Add(innerFunction);
                    }
                });
            }

            if (!template.HasMember("Container"))
            {
                template.AddMember(new PropertyMember("Container", "IContainer", "IContainer", AccessModifier._Public, "_container", "IContainer", "IContainer", true, true, null, true));
            }

            IMember controlMember = new InstantiatedControlMember(id, type, customInstantiate, additionalProperties, dependencies);

            template.AddMember(controlMember);

            currentRenderFunction.AddFragment(new InstantiatedControlFragment(id, customInstantiate, numInnerFragments));
            currentRenderFunction.AddDependency(controlMember);

            return(true);
        }