コード例 #1
0
        private static bool ScriptShouldRun(
            SqlScript sqlScript,
            IEnumerable <string> executedScriptNames,
            ScriptNameComparer comparer,
            IEnumerable <ExecutedSqlScript> executedScripts,
            IHasher hasher)
        {
            switch (sqlScript.SqlScriptOptions.ScriptType)
            {
            case ScriptType.RunAlways:
                return(true);

            case ScriptType.RunOnce:
                return(!executedScriptNames.Contains(sqlScript.Name, comparer));

            case ScriptType.RunOnChange:
            {
                if (executedScripts == null)
                {
                    throw new ArgumentNullException(nameof(executedScripts));
                }

                if (hasher == null)
                {
                    throw new ArgumentNullException(nameof(hasher));
                }

                return(DefaultScriptFilter.ScriptIsNewOrChanged(sqlScript, comparer, executedScripts, hasher));
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #2
0
 public IEnumerable <SqlScript> Filter(
     IEnumerable <SqlScript> sorted,
     HashSet <string> executedScriptNames,
     ScriptNameComparer comparer)
 {
     return(sorted.Where(sqlScript => DefaultScriptFilter.ScriptShouldRun(sqlScript, executedScriptNames, comparer, null, null)));
 }
コード例 #3
0
        public IEnumerable <SqlScript> Filter(
            IOrderedEnumerable <SqlScript> sorted,
            IEnumerable <ExecutedSqlScript> executedScripts,
            ScriptNameComparer comparer,
            IHasher hasher)
        {
            var executedScriptsList = executedScripts.ToList();
            var executedScriptNames = new HashSet <string>(executedScriptsList.Select(x => x.Name), comparer);

            return(sorted.Where(sqlScript => DefaultScriptFilter.ScriptShouldRun(sqlScript, executedScriptNames, comparer, executedScriptsList, hasher)));
        }