Skip to content

Commit

Permalink
Added support for Case directives in Custom Tags
Browse files Browse the repository at this point in the history
  • Loading branch information
victoryoalli committed Feb 25, 2015
1 parent 04d4388 commit a6ed8b7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/DatabaseStructure/MySQL/ColumnStrategyMySQL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected override Column CreateColumn(DataRow row)
column.Length = 0;
}

column.Nullable = (row["Null"].ToString() != null && row["Null"].ToString().Length == 0) ? false: true;
column.Nullable = (row["Null"].ToString() != null && row["Null"].ToString().Length == 0);
column.Default = row["Default"].ToString();
return column;
}
Expand Down
22 changes: 20 additions & 2 deletions src/Generator/Expressions/LiteralExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace iCodeGenerator.Generator
{
public class LiteralExpression : Expression
{
private string _strKey;
private string _strValue;
private readonly string _strKey;
private readonly string _strValue;
public LiteralExpression(string strKey,string strValue)
{
_strKey = strKey;
Expand All @@ -16,6 +16,24 @@ public override void Interpret(Context context)
{
context.Output = Regex.Replace(context.Input,Context.StartDelimeter + _strKey + Context.EndingDelimiter,_strValue);
context.Input = context.Output;
var inputPattern = Context.StartDelimeter + _strKey + @"\s*" +
@"(?<naming>(CAMEL|PASCAL|HUMAN|UNDERSCORE|UPPER|LOWER))*"+
Context.EndingDelimiter;

var regex = new Regex(inputPattern, RegexOptions.Singleline);
var inputString = context.Input;
var matches = regex.Matches(inputString);
foreach(Match match in matches)
{
var matchString = match.Value;
var naming = match.Groups["naming"].ToString();
var replacement = _strValue;
replacement = CaseConvertion(naming, replacement, _strValue);
inputString = Regex.Replace(inputString, matchString, replacement);
}
context.Output = inputString;
context.Input = context.Output;
}

}
}
8 changes: 4 additions & 4 deletions src/Generator/FileGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ public void Generate(Table table,string inputDir, string outputDir)
{
var directoryInfo = new DirectoryInfo(inputDir);
var client = new Client();
var originalSd = client.StartDelimiter;
var originalEd = client.EndingDelimiter;
//var originalSd = client.StartDelimiter;
//var originalEd = client.EndingDelimiter;
if(_CustomValue != null)
{
client.CustomValues = _CustomValue;
}
foreach(var fileInfo in directoryInfo.GetFiles())
{
client.StartDelimiter = originalSd;
client.EndingDelimiter = originalEd;
client.StartDelimiter = "{";//originalSd;
client.EndingDelimiter = "}";//originalEd;
var sr = File.OpenText(fileInfo.FullName);
var fileContent = sr.ReadToEnd();
sr.Close();
Expand Down
2 changes: 1 addition & 1 deletion src/iCodeGeneratorGui/MainApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void DnfDatabaseSelected(object sender, DatabaseEventArgs args)
{
_pf.SelectedObject = args.Database;
}

private void DnfTableSelected(object sender, TableEventArgs args)
{
_selectedTable = args.Table;
Expand Down

0 comments on commit a6ed8b7

Please sign in to comment.