예제 #1
0
파일: Parser.cs 프로젝트: Acraciel/Gale
        internal String CallOperator(string filter, Model model)
        {
            string _property = null;
            string _operator = null;
            string _value = null;

            string trimmed = filter.Trim();
            char charKey = ' ';

            //Property
            int charKeyPosition = trimmed.IndexOf(charKey);
            if (charKeyPosition >= 0)
            {
                _property = trimmed.Substring(0, charKeyPosition).ToLower();
                trimmed = trimmed.Substring(charKeyPosition).Trim();
            }

            //Operator
            charKeyPosition = trimmed.IndexOf(charKey);
            if (charKeyPosition >= 0)
            {
                _operator = trimmed.Substring(0, charKeyPosition).ToLower();
                trimmed = trimmed.Substring(charKeyPosition).Trim();
            }

            //Value Sanitization
            _value = trimmed.Replace("%", "").Replace("'", "");

            if (!String.IsNullOrEmpty(_property) && !String.IsNullOrEmpty(_operator) && !String.IsNullOrEmpty(_value) )
            {

                Field field = (from t in model.Fields where t.Name == _property select t).FirstOrDefault();

                if (field == null)
                {
                    throw new Gale.Exception.GaleException("API005", _property, filter);
                }

                return _callOperator(_operator, field, _value);
            }
            else
            {
                throw new Gale.Exception.GaleException("API006", filter);
            }
        }
예제 #2
0
파일: Parser.cs 프로젝트: Acraciel/Gale
 public abstract String Parse(String query, Model model);