private string Intrepret() { var parser = new Parser(_Table); var columnsExp = new ColumnsExpression(); columnsExp.AddExpression(new ColumnIfTypeExpression()); columnsExp.AddExpression(new ColumnNameExpression()); columnsExp.AddExpression(new ColumnTypeExpression()); columnsExp.AddExpression(new ColumnCommentExpression()); columnsExp.AddExpression(new ColumnLengthExpression()); columnsExp.AddExpression(new ColumnDefaultExpression()); columnsExp.AddExpression(new ColumnMapTypeExpression()); columnsExp.AddExpression(new ColumnIfExpression()); columnsExp.AddExpression(new ColumnIfNullableExpression()); columnsExp.AddExpression(new ColumnNameMatchesExpression()); parser.AddExpression(columnsExp); parser.AddExpression(new TableNameExpression()); parser.AddExpression(new TableSchemaExpression()); parser.AddExpression(new DatabaseNameExpression()); if (_CustomValues != null) { foreach (DictionaryEntry entry in _CustomValues) { parser.AddExpression(new LiteralExpression(entry.Key.ToString(), entry.Value.ToString())); } } if (!String.IsNullOrEmpty(ReplaceText)) { parser.AddExpression(new TextRemoveExpression(ReplaceText)); } parser.Interpret(_Context); return(_Context.Output); }
public void TestTableColumnsClass() { _context.Input = @"public class {TABLE.NAME}{ {TABLE.COLUMNS} private {MAP COLUMN.TYPE} _{COLUMN.NAME}; //{COLUMN.LENGHT} {TABLE.NULLABLE} {/TABLE.COLUMNS} public void {TABLE.NAME}(){ } {TABLE.COLUMNS} //{TABLE.NAME} public {MAP COLUMN.TYPE} {COLUMN.NAME} { set{ _{COLUMN.NAME} = value; } get{ return _{COLUMN.NAME}; } } {/TABLE.COLUMNS} } "; ColumnsExpression columns = new ColumnsExpression(); columns.AddExpression(new ColumnNameExpression()); columns.AddExpression(new ColumnTypeExpression()); columns.AddExpression(new ColumnMapTypeExpression()); //columns.AddExpression(new LiteralExpression("[A-Z. ]+","")); _parser.AddExpression(columns); _parser.AddExpression(new TableNameExpression()); _parser.Interpret(_context); }
private string Intrepret() { var parser = new Parser(_Table); var columnsExp = new ColumnsExpression(); columnsExp.AddExpression(new ColumnIfTypeExpression()); columnsExp.AddExpression(new ColumnNameExpression()); columnsExp.AddExpression(new ColumnTypeExpression()); columnsExp.AddExpression(new ColumnLengthExpression()); columnsExp.AddExpression(new ColumnDefaultExpression()); columnsExp.AddExpression(new ColumnMapTypeExpression()); columnsExp.AddExpression(new ColumnIfExpression()); columnsExp.AddExpression(new ColumnIfNullableExpression()); columnsExp.AddExpression(new ColumnNameMatchesExpression()); parser.AddExpression(columnsExp); parser.AddExpression(new TableNameExpression()); parser.AddExpression(new TableSchemaExpression()); parser.AddExpression(new DatabaseNameExpression()); if(_CustomValues != null) { foreach(DictionaryEntry entry in _CustomValues) { parser.AddExpression(new LiteralExpression(entry.Key.ToString(),entry.Value.ToString())); } } parser.Interpret(_Context); return _Context.Output; }
private string Intrepret() { Parser parser = new Parser(_table); ColumnsExpression columnsExp = new ColumnsExpression(); columnsExp.AddExpression(new ColumnIfTypeExpression()); columnsExp.AddExpression(new ColumnNameExpression()); columnsExp.AddExpression(new ColumnTypeExpression()); columnsExp.AddExpression(new ColumnLengthExpression()); columnsExp.AddExpression(new ColumnDefaultExpression()); columnsExp.AddExpression(new ColumnMapTypeExpression()); columnsExp.AddExpression(new ColumnIfExpression()); columnsExp.AddExpression(new ColumnIfNullableExpression()); columnsExp.AddExpression(new ColumnNameMatchesExpression()); parser.AddExpression(columnsExp); parser.AddExpression(new TableNameExpression()); parser.AddExpression(new DatabaseNameExpression()); if (_CustomValues != null) { foreach (DictionaryEntry entry in _CustomValues) { parser.AddExpression(new LiteralExpression(entry.Key.ToString(), entry.Value.ToString())); } } parser.Interpret(_context); return(_context.Output); }
public void TestColumnNameMatchesExpression() { _context.Input = @"{TABLE.COLUMNS}"+ @"{IF COLUMN.NAME =~ 'Id$'}{COLUMN.NAME} ES ID{/IF}" + "\n"+ @"{IF COLUMN.NAME !~ 'Id$'}{COLUMN.NAME}{/IF}"+ "\n"+ "{/TABLE.COLUMNS}"; ColumnsExpression columns = new ColumnsExpression(); columns.AddExpression(new ColumnNameExpression()); columns.AddExpression(new ColumnNameMatchesExpression()); _parser.AddExpression(columns); _parser.Interpret(_context); }
public void TestColumnsIfLast() { _context.Input = @"{TABLE.COLUMNS} {IF NOT LAST}NOT LAST{/IF} {IF LAST} LAST{/IF} {/TABLE.COLUMNS}"; ColumnsExpression columns = new ColumnsExpression(); columns.AddExpression(new ColumnIfExpression()); _parser.AddExpression(columns); _parser.Interpret(_context); }
public void TestColumnNaming() { _context.Input = @"{TABLE.COLUMNS}" + @"Normal: {COLUMN.NAME}" + "\n" + // @"Camel: {COLUMN.NAME CAMEL}" + "\n" + // @"Pascal: {COLUMN.NAME PASCAL}" + "\n" + // @"Upper: {COLUMN.NAME UPPER}" + "\n" + // @"Lower: {COLUMN.NAME LOWER}" + "\n" + @"Underscore: {COLUMN.NAME UNDERSCORE}" + "\n" + @"Human: {COLUMN.NAME HUMAN}" + "\n" + @"{/TABLE.COLUMNS}"; ColumnsExpression columns = new ColumnsExpression(); columns.AddExpression(new ColumnNameExpression()); _parser.AddExpression(columns); _parser.Interpret(_context); // Console.WriteLine(_context.Output); }
public void TestTableColumnsSQL() { _context.Input = @"CREATE PROCEDURE sp{TABLE.NAME}_Insert( {TABLE.COLUMNS NOPRIMARY} @{COLUMN.NAME} {COLUMN.TYPE}, {/TABLE.COLUMNS}{TABLE.COLUMNS PRIMARY}@{COLUMN.NAME} {COLUMN.TYPE} OUTPUT{/TABLE.COLUMNS} ) AS INSERT INTO {TABLE.NAME} ({TABLE.COLUMNS}{COLUMN.NAME}{IF NOT LAST},{/IF} {/TABLE.COLUMNS}) VALUES({TABLE.COLUMNS}@{COLUMN.NAME}{IF NOT LAST},{/IF} {/TABLE.COLUMNS}) {TABLE.COLUMNS PRIMARY} SET @{COLUMN.NAME} = @{COLUMN.NAME} {/TABLE.COLUMNS} "; ColumnsExpression columns = new ColumnsExpression(); columns.AddExpression(new ColumnNameExpression()); columns.AddExpression(new ColumnTypeExpression()); columns.AddExpression(new ColumnLengthExpression()); columns.AddExpression(new ColumnIfExpression()); _parser.AddExpression(columns); _parser.AddExpression(new TableNameExpression()); _parser.Interpret(_context); }
public void TestIfNullable() { _context.Input = @"{TABLE.COLUMNS}{IF COLUMN.NULLABLE}{COLUMN.NAME}=NULL{/IF}{IF NOT COLUMN.NULLABLE}FALSE{/IF} {/TABLE.COLUMNS}"; ColumnsExpression columns = new ColumnsExpression(); columns.AddExpression(new ColumnNameExpression()); columns.AddExpression(new ColumnIfNullableExpression()); _parser.AddExpression(columns); _parser.Interpret(_context); }
public void TestIfType() { _context.Input = @" {TABLE.COLUMNS} {IF COLUMN.TYPE EQ 'int|numeric()'}int _{COLUMN.NAME}{/IF} {IF COLUMN.TYPE NE 'int'}string _{COLUMN.NAME}{/IF} {/TABLE.COLUMNS}"; ColumnsExpression colsExpression = new ColumnsExpression(); colsExpression.AddExpression(new ColumnIfTypeExpression()); colsExpression.AddExpression(new ColumnNameExpression()); _parser.AddExpression(colsExpression); _parser.Interpret(_context); }
public void TestColumnsNoPrimary() { _context.Input = @"{TABLE.COLUMNS NOPRIMARY}{COLUMN.NAME} {/TABLE.COLUMNS}"; ColumnsExpression columns = new ColumnsExpression(); columns.AddExpression(new ColumnNameExpression()); _parser.AddExpression(columns); _parser.Interpret(_context); }