Пример #1
0
        private void SetupParser(JToken jsonObject)
        {
            var compatabilityLevel = jsonObject.SelectTokens("..compatability-level").FirstOrDefault()?.ToString();

            int.TryParse(compatabilityLevel, out var parsedCompatabilityLevel);
            CompatabilityLevel = CompatabilityLevelUtility.ValidateCompatabilityLevel(parsedCompatabilityLevel);
        }
Пример #2
0
        private static TSqlParser GetSqlParser(int compatabilityLevel)
        {
            compatabilityLevel = CompatabilityLevelUtility.ValidateCompatabilityLevel(compatabilityLevel);

            var fullyQualifiedName = string.Format("Microsoft.SqlServer.TransactSql.ScriptDom.TSql{0}Parser", compatabilityLevel);
            var type = Type.GetType(fullyQualifiedName);

            TSqlParser parser = new TSql120Parser(true);

            foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                type = asm.GetType(fullyQualifiedName);
                if (type != null)
                {
                    parser = (TSqlParser)Activator.CreateInstance(type, new object[] { true });
                    break;
                }
            }

            return(parser);
        }
Пример #3
0
 public FragmentBuilder(int compatabilityLevel)
 {
     parser = GetSqlParser(CompatabilityLevelUtility.ValidateCompatabilityLevel(compatabilityLevel));
 }