Esempio n. 1
0
        public static Option <UpgradeEngineBuilder, Error> SelectScripts(this Option <UpgradeEngineBuilder, Error> builderOrNone, IList <ScriptBatch> scripts)
        {
            if (scripts == null)
            {
                throw new ArgumentNullException(nameof(scripts));
            }

            if (scripts.Count == 0)
            {
                return(Option.None <UpgradeEngineBuilder, Error>(Error.Create(Constants.ConsoleMessages.ScriptShouldPresent)));
            }

            foreach (var script in scripts)
            {
                if (!Directory.Exists(script.Folder))
                {
                    return(Option.None <UpgradeEngineBuilder, Error>(Error.Create(Constants.ConsoleMessages.FolderNotFound, script.Folder)));
                }
            }

            foreach (var script in scripts)
            {
                builderOrNone = builderOrNone.AddScripts(script);
            }

            return(builderOrNone);
        }