Beispiel #1
0
        private String load(String fn, ITemplateFactory templatefactory)
        {
            Regex refExpr  = new Regex("^//@ref=(.*)$", RegexOptions.IgnoreCase | RegexOptions.IgnoreCase);
            Regex inclExpr = new Regex("^//@incl=(.*)$", RegexOptions.IgnoreCase | RegexOptions.IgnoreCase);

            ITemplateEngine template = templatefactory.CreateEngine();

            template.LoadFromFile(fn);
            String outputFile = template.WriteGeneratedOutput();
            var    rdr        = template.ResultAsReader();

            String dir = Path.GetDirectoryName(fn);

            while (true)
            {
                String line = rdr.ReadLine();
                String val1;
                if (line == null)
                {
                    break;
                }

                if (line.Length < 5)
                {
                    continue;
                }
                if (line[0] != '/')
                {
                    continue;
                }
                if (refExpr.IsMatch(line))
                {
                    val1 = refExpr.Replace(line, "$1");
                    ScriptHost.logger.Log("handling REF: '{0}'", val1);
                    if (!String.IsNullOrEmpty(val1))
                    {
                        References.Add(val1);
                    }
                    continue;
                }
                if (inclExpr.IsMatch(line))
                {
                    val1 = inclExpr.Replace(line, "$1");
                    ScriptHost.logger.Log("handling INCL: '{0}'", val1);
                    if (!String.IsNullOrEmpty(val1))
                    {
                        Includes.Add(IOUtils.FindFileToRoot(dir, val1, FindToTootFlags.Except));
                    }
                    continue;
                }
            }
            return(outputFile);
        }