public override void Interpret(Context context)
		{
			Regex regex = new Regex(InputPattern,RegexOptions.Singleline);
			MatchCollection matches = regex.Matches(context.Input);			
			foreach(Match match in matches)
			{
				string columnOutput = "";
				string columnInput = match.Groups["column"].Value;				
				ColumnCollection columns = ((Table)Parameter).Columns;
				ColumnCollection filteredColumns = new ColumnCollection();
				foreach(Column column in columns)
				{
					if(IsValidColumn(column,match.Groups["selection"].Value.Trim()))
					{
						filteredColumns.Add(column);
					}
				}
				foreach(Column column in filteredColumns)
				{					
					string columnTemporaryText = columnInput;
					RunExpressionsReplace(column, filteredColumns, ref columnTemporaryText);
					columnOutput += columnTemporaryText;
				}
				string escapedString = Regex.Escape( match.Value );
				context.Output = Regex.Replace(context.Input ,escapedString,columnOutput);
				context.Input = context.Output;
			}									
		}
		public override void Interpret(Context context)
		{			
			Column column = (Column)Parameter;

			Regex regex = new Regex(InputPattern,RegexOptions.Singleline);
			string inputString = context.Input;
			MatchCollection matches = regex.Matches(inputString);
			foreach(Match match in matches)
			{
				if(match.Length == 0)
				{
					continue;
				}
				string matchString = match.Value;
				string contentString = match.Groups["content"].ToString();
				string endString = match.Groups["end"].ToString();
				string replacementString = contentString + endString;
				bool isIfNullable = !( match.Groups["not"].ToString().IndexOf("NOT") != -1);
				bool isIfNotNullable = !isIfNullable;
				if(isIfNotNullable && !column.Nullable)
				{
					ReplaceContent(matchString,replacementString,ref inputString);
				}
				else if(isIfNullable && column.Nullable)
				{
					ReplaceContent(matchString,replacementString,ref inputString);
				}
				else
				{
					ReplaceContent(match.Value, "", ref inputString);
				}
				context.Output = inputString;
				context.Input = context.Output;
			}
		}
Beispiel #3
0
		public override void Interpret(Context context)
		{
			foreach(Expression expression in  _expressions)
			{
				expression.Parameter = _table;
				expression.Interpret(context);
			}
		}
		private void RunExpressionsReplace(Column column, object columns, ref string columnInputText)
		{
			Context columnContext = new Context();
			columnContext.Extra = columns;
			foreach(Expression expression in _expressions)
			{																					
				columnContext.Input = columnInputText;						
				expression.Parameter = column;
				expression.Interpret(columnContext);
				columnInputText = columnContext.Output;
			}
		}
        public override void Interpret(Context context)
        {
            Table table = (Table)Parameter;
            Regex regex = new Regex(InputPattern, RegexOptions.Singleline);
            string inputString = context.Input;
            MatchCollection matches = regex.Matches(inputString);
            foreach (Match match in matches)
            {
                string matchString = match.Value;
                string naming = match.Groups["naming"].ToString();
                string replacement = table.Name;
                switch (naming)
                {
                    case "CAMEL":
                        replacement = CamelReplacement(table);
                        break;
                    case "PASCAL":
                        replacement = PascalReplacement(table);
                        break;
                    case "LOWER":
                        replacement = LowerReplacement(table);
                        break;
                    case "UPPER":
                        replacement = UpperReplacement(table);
                        break;
                    case "UNDERSCORE":
                        replacement = UnderscoreReplacement(replacement);
                        break;
                    case "HUMAN":
                        replacement = HumanReplacement(replacement);
                        break;
                    case "REMOVEPREFIX_LOWER_FIRSTUPPER":
                        replacement = RemovePrefixLowerFirstUpperReplacement(table);
                        break;
                    case "REMOVEPREFIX_UPPER":
                        replacement = RemovePrefixUpperReplacement(table);
                        break;
                    case "REMOVEPREFIX_LOWER":
                        replacement = RemovePrefixLowerReplacement(table);
                        break;
                    default:
                        break;
                }
                inputString = Regex.Replace(inputString, matchString, replacement);
            }
            context.Output = inputString;
            context.Input = context.Output;

            //			Column column = (Column)Parameter;
            //			context.Output = Regex.Replace(context.Input,
            //				InputPattern,
            //			    column.Name);
        }
        public override void Interpret(Context context)
        {
            Column column = (Column) Parameter;
            Regex regex = new Regex(InputPattern, RegexOptions.Singleline);
            string inputString = context.Input;
            MatchCollection matches = regex.Matches(inputString);
            foreach (Match match in matches)
            {
                if (match.Length == 0)
                {
                    continue;
                }
                bool isEqual = (match.Groups["equality"].ToString().IndexOf("EQ") != -1);
                bool isNotEqual = (match.Groups["equality"].ToString().IndexOf("NE") != -1);
                string contentString = match.Groups["content"].ToString();
                string typeValueString = match.Groups["typeValue"].ToString();
                string endString = match.Groups["end"].ToString();
                string replacementString = contentString + endString;

                bool isAMatch = false;
            //				Console.WriteLine(typeValueString);
                string[] valueStrings = typeValueString.Split('|');
                for (int i = 0; i < valueStrings.Length; i++)
                {
                    valueStrings[i] = valueStrings[i].Trim();
                    if (isEqual && (column.Type.ToLower() == valueStrings[i].ToLower()))
                    {
                        ReplaceContent(match.Value, replacementString, ref inputString);
                        isAMatch = true;
                        break;
                    }
                    else if (isNotEqual && (column.Type.ToLower() != valueStrings[i].ToLower()))
                    {
                        ReplaceContent(match.Value, replacementString, ref inputString);
                        isAMatch = true;
                        break;
                    }
                }
                if (!isAMatch)
                {
                    ReplaceContent(match.Value, "", ref inputString);
                }
            }
            context.Output = inputString;
            context.Input = context.Output;
        }
		public override void Interpret(Context context)
		{			
			var column = (Column) Parameter;
			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 = column.Name;
				replacement = Expression.CaseConvertion(naming, replacement, column.Name);
				inputString = Regex.Replace(inputString, matchString, replacement);
			}
			context.Output = inputString;
			context.Input = context.Output;
		}
		public override void Interpret(Context context)
		{
			Column column = (Column)Parameter;
			string strValue = "";
			IDictionary mappings = Mappings;
			if(mappings.Contains(column.Type.ToLower()))
			{				
             	strValue = mappings[column.Type.ToLower()].ToString();
			}
			else
			{
				strValue = "object";
			}
			
			context.Output = Regex.Replace(context.Input,Context.StartDelimeter + "MAP COLUMN.TYPE" + Context.EndingDelimiter,strValue);
			context.Input = context.Output;
		}
		public override void Interpret(Context context)
		{	
			Regex regex = new Regex(InputPattern,RegexOptions.Singleline);
			string inputString = context.Input;
			MatchCollection matches = regex.Matches(inputString);
			ColumnCollection columns = (ColumnCollection) context.Extra;
			bool IsLastColumn = (columns.Count == (columns.IndexOf((Column)Parameter) + 1));

			foreach(Match match in matches)
			{
				bool IsIfNotLast;
				string matchString = match.Value;
				if(match.Length != 0)
				{
					string content = "";
					string endString = "";
					content = match.Groups["content"].ToString();
					endString = match.Groups["end"].ToString();
					string replacementString = content + endString;
					IsIfNotLast = (match.Groups["not"].ToString().Length != 0);
					bool IsIfLast = !IsIfNotLast;
					if( IsIfNotLast && IsLastColumn )
					{
						ReplaceContent(matchString, "", ref inputString);
					}
					else if( IsIfLast && IsLastColumn )
					{
						ReplaceContent(matchString, replacementString, ref inputString);
					}
					else if( IsIfNotLast && !IsLastColumn )
					{
						ReplaceContent(matchString, replacementString, ref inputString);
					}
					else if( IsIfLast && !IsLastColumn )
					{
						ReplaceContent(matchString, "", ref inputString);
					}
				}	
			}			
			context.Output = inputString;
			context.Input = context.Output;
		}
        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;
        }
        public override void Interpret(Context context)
        {
            Column column = (Column) Parameter;
            Regex regex = new Regex(InputPattern, RegexOptions.Singleline);
            string inputString = context.Input;
            MatchCollection matches = regex.Matches(inputString);
            foreach(Match match in matches)
            {
                if (match.Length == 0)
                    continue;
                bool isEqual = (match.Groups["equality"].ToString().IndexOf("=~") != -1);
                bool isNotEqual = (match.Groups["equality"].ToString().IndexOf("!~") != -1);
                string contentString = match.Groups["content"].ToString();
                string regularExp = match.Groups["regularExp"].ToString();
                string endString = match.Groups["end"].ToString();
                string replacementString = contentString + endString;
                bool isAMatch = false;

                if (isEqual &&  Regex.IsMatch(column.Name,regularExp ))
                {
                    isAMatch = true;
                    ReplaceContent(match.Value, replacementString, ref inputString);
                }
                else if(isNotEqual &&  !Regex.IsMatch(column.Name,regularExp ))
                {
                    isAMatch = true;
                    ReplaceContent(match.Value, replacementString, ref inputString);
                }

                if (!isAMatch)
                {
                    ReplaceContent(match.Value, "", ref inputString);
                }

            }

            context.Output = inputString;
            context.Input = context.Output;
        }
 public override void Interpret(Context context)
 {
     Column column = (Column)Parameter;
     context.Output = Regex.Replace(context.Input,Context.StartDelimeter + "COLUMN.TYPE" + Context.EndingDelimiter,column.Type);
     context.Input = context.Output;
 }
		public override void Interpret(Context context)
		{
			Column column = (Column)Parameter;
			context.Output = Regex.Replace(context.Input,Context.StartDelimeter + "COLUMN.LENGTH" + Context.EndingDelimiter,column.Length.ToString());
			context.Input = context.Output;
		}
Beispiel #14
0
		public Client()
		{
			_Context = new Context();
		}
 public override void Interpret(Context context)
 {
     Database database = ((Table)Parameter).ParentDatabase;
     context.Output = Regex.Replace(context.Input,Context.StartDelimeter + "DATABASE.NAME" + Context.EndingDelimiter,database.Name);
     context.Input = context.Output;
 }
Beispiel #16
0
 public abstract void Interpret(Context context);
 public override void Interpret(Context context)
 {
     context.Output = Regex.Replace(context.Input,Context.StartDelimeter + _strKey + Context.EndingDelimiter,_strValue);
     context.Input = context.Output;
 }