Beispiel #1
0
        protected override string OnGenerateCode(string inputFileName, string inputFileContent)
        {
            // TODO: Build list of processing instructions from config?
            XmlReaderSettings set = new XmlReaderSettings();

            set.IgnoreWhitespace = true;
            set.CheckCharacters  = true;
            using (XmlReader reader = XmlReader.Create(inputFileName, set))
            {
                Dictionary <string, IInlineInstruction> inlines = new Dictionary <string, IInlineInstruction>();
                inlines.Add("foreach", new ForEachInstruction());
                inlines.Add("if", new IfInstruction());
                inlines.Add("elseif", new ElseIfInstruction());
                inlines.Add("else", new ElseInstruction());
                inlines.Add("end", new EndInstruction());

                Dictionary <string, ITypeInstruction> typeInst = new Dictionary <string, ITypeInstruction>();
                typeInst.Add("template", new TemplateInstruction());
                typeInst.Add("using", new UsingInstruction());
                typeInst.Add("property", new PropertyInstruction());

                XmlCodeGenerator generator = new XmlCodeGenerator(
                    typeInst,
                    inlines,
                    FileNameSpace,
                    Path.GetFileNameWithoutExtension(inputFileName));

                CodeNamespace ns = generator.GenerateCode(reader);
                return(GenerateCode(ns));
            }
        }
Beispiel #2
0
		protected override string OnGenerateCode(string inputFileName, string inputFileContent)
		{
			// TODO: Build list of processing instructions from config?
			XmlReaderSettings set = new XmlReaderSettings();
			set.IgnoreWhitespace = true;
			set.CheckCharacters = true;
			using (XmlReader reader = XmlReader.Create(inputFileName, set))
			{
				Dictionary<string, IInlineInstruction> inlines = new Dictionary<string, IInlineInstruction>();
				inlines.Add("foreach", new ForEachInstruction());
				inlines.Add("if", new IfInstruction());
				inlines.Add("elseif", new ElseIfInstruction());
				inlines.Add("else", new ElseInstruction());
				inlines.Add("end", new EndInstruction());

				Dictionary<string, ITypeInstruction> typeInst = new Dictionary<string, ITypeInstruction>();
				typeInst.Add("template", new TemplateInstruction());
				typeInst.Add("using", new UsingInstruction());
				typeInst.Add("property", new PropertyInstruction());

				XmlCodeGenerator generator = new XmlCodeGenerator(
					typeInst,
					inlines,
					FileNameSpace,
					Path.GetFileNameWithoutExtension(inputFileName));

				CodeNamespace ns = generator.GenerateCode(reader);
				return GenerateCode(ns);
			}
		}