Пример #1
0
 public StatementExcavator(ParserOption options, string sourceCode)
 {
     Options = options;
     SourceCode = sourceCode;
     if (Cached == null)
         Cached = new Dictionary<Guid, CompilerResults>();
 }
Пример #2
0
        public void ParserTest()
        {
            var builder = new DBBuilder(new DBConnection
                                            {
                                                Account = "gonnatour",
                                                DBType = DataBaseType.MSSQL,
                                                Name = "gonnatour",
                                                Password = "******",
                                                Server = "localhost"
                                            });
            DataBase database = builder.Build();
            var options = new ParserOption();

            foreach (Table table in database.Tables)
            {
                options.VariableParameter = table;
                table.Columns = table.Columns.OrderByDescending(t => t.PrimaryKey).ThenBy(t => t.Name).ToList();
                options.StatementParameters = new object[] { database, table };
                options.Namesapces.Add("xCoder.DB2Project.Data");
                options.References.Add("System.dll");
                options.References.Add(@".\xCoder.DB2Project.dll");
                options.SourceCode = new FileInfo("./testdata/test2.tpl");
                var parser = new Parser(options);
                string temp = parser.Parse(ParserType.XCODER);
                Console.WriteLine(temp);
            }
        }
Пример #3
0
        public override string[] Build()
        {
            var options = new ParserOption();
            var currentAssembly = GetType().Assembly;
            var name = new FileInfo(currentAssembly.Location).Name;
            var namespaces = currentAssembly.GetTypes().Select(t => t.Namespace).ToArray();
            options.Namesapces.AddRange(namespaces);
            options.References.Add("System.dll");
            options.References.Add(@".\" + name);
            options.SourceCode = Parameters.Template;
            options.VariableCollection.Add("Namespace",
                                           string.IsNullOrEmpty(Parameters.Namespace) ? "" : Parameters.Namespace);
            var tmp = new List<string>();
            foreach (Table table in Parameters.DataBase.Tables)
            {
                options.VariableParameter = table;
                options.StatementParameters = new object[] {Parameters.DataBase, table};

                var parser = new Parser.Parser(options);
                string temp = parser.Parse(ParserType.XCODER);
                string fileName = Path.Combine(Parameters.OutputDirectory.FullName, table.Name) + Extension;
                File.WriteAllText(fileName, temp);
                tmp.Add(fileName);
            }
            return tmp.ToArray();
        }
Пример #4
0
 protected ParserBase(ParserOption options, string tagRegx)
 {
     Options = options;
     TagRegx = tagRegx;
     BaseRegex = new Regex(TagRegx.Replace(@"\r", string.Empty).Replace("\n", string.Empty), RegxOptions);
     if ((Options.SourceCode == null || !Options.SourceCode.Exists) && Options.Code == null)
     {
         throw new InvalidDataException("XCoderOptions: Code File To be parsed can not be found");
     }
     TemplateContent = Options.Code != null
                           ? Options.Code.ToString()
                           : File.ReadAllText(options.SourceCode.FullName);
     Results = new List<string>();
 }
Пример #5
0
 public Parser(ParserOption options)
 {
     Options = options;
 }
Пример #6
0
 public VariableParser(ParserOption options)
     : base(options, "<#(.[^#>]*[^<#]{0})#>")
 {
 }