コード例 #1
0
        private IDictionary <string, SqlVariable> GetVariables_WithDataTypes(string sqlText)
        {
            IDictionary <string, SqlVariable> result = new Dictionary <string, SqlVariable>();

            string expression = ResManager.GetRegularExpression("SqlAnalyze_VariableWithDataType");

            expression = SqlAnalyzeHelper.ReplaceDataTypesWithQualifiedOnes(expression);

            //Regex r = new Regex(expression, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            Match m;

            SqlVariable v = null;
            Group       g = null;

            for (m = Regex.Match(sqlText, expression, RegexOptions.IgnoreCase); m.Success; m = m.NextMatch())
            {
                g = m.Groups["Name"];
                if (g == null)
                {
                    continue;
                }

                string dName = String.Empty;

                if (result.ContainsKey(g.Value))
                {
                    continue;
                }

                dName  = SqlAnalyzeHelper.CleanIdentifier(g.Value);
                v      = new SqlVariable();
                v.Name = dName;
                v.FullyQualifiedName = dName;
                g = m.Groups["DataType"];
                result.Add(dName, v);

                if (g != null)
                {
                    v.DataType            = SqlAnalyzeHelper.CleanIdentifier(g.Value);
                    v.FullyQualifiedName += " " + v.DataType;
                }
            }
            return(result);
        }
コード例 #2
0
        private IDictionary <string, SqlVariable> GetVariables_NameOnly(string sqlText)
        {
            IDictionary <string, SqlVariable> result = new Dictionary <string, SqlVariable>();

            string expression = ResManager.GetRegularExpression("SqlAnalyze_VariableNameOnly");

            Match m = null;

            SqlVariable v = null;

            for (m = Regex.Match(sqlText, expression, RegexOptions.IgnoreCase); m.Success; m = m.NextMatch())
            {
                if (!result.ContainsKey(m.Value))
                {
                    v      = new SqlVariable();
                    v.Name = m.Value;
                    v.FullyQualifiedName = m.Value;
                    result.Add(m.Value, v);
                }
            }
            return(result);
        }