Пример #1
0
 public static SqlScriptOptions GetSqlScriptOptions(ScriptBatch batch) =>
 new SqlScriptOptions()
 {
     ScriptType    = batch.RunAlways ? Support.ScriptType.RunAlways : Support.ScriptType.RunOnce,
     RunGroupOrder = batch.Order
 };
Пример #2
0
        public static Option <FileSystemScriptOptions, Error> GetFileSystemScriptOptions(ScriptBatch batch)
        {
            if (batch == null)
            {
                throw new ArgumentNullException(nameof(batch));
            }
            if (batch.Encoding == null)
            {
                throw new ArgumentNullException(nameof(batch.Encoding), "Encoding can't be null");
            }

            Encoding encoding = null;

            try
            {
                encoding = Encoding.GetEncoding(batch.Encoding);
            }
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
            catch
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
            {
            }
            if (encoding == null)
            {
                try
                {
                    encoding = CodePagesEncodingProvider.Instance.GetEncoding(batch.Encoding);
                }
                catch (ArgumentException ex)
                {
                    return(Option.None <FileSystemScriptOptions, Error>(Error.Create(Constants.ConsoleMessages.InvalidEncoding, batch.Folder, ex.Message)));
                }
            }

            return(new FileSystemScriptOptions()
            {
                IncludeSubDirectories = batch.SubFolders,
                Encoding = encoding,
                Filter = CreateFilter(batch.Filter, batch.MatchFullPath)
            }.Some <FileSystemScriptOptions, Error>());
        }
Пример #3
0
 static Option <UpgradeEngineBuilder, Error> AddScripts(this Option <UpgradeEngineBuilder, Error> builderOrNone, ScriptBatch script) =>
 builderOrNone.Match(
     some: builder =>
     GetFileSystemScriptOptions(script).Match(
         some: options =>
 {
     builder.WithScripts(
         new FileSystemScriptProvider(
             script.Folder,
             options,
             GetSqlScriptOptions(script)));
     return(builder.Some <UpgradeEngineBuilder, Error>());
 },
         none: error => Option.None <UpgradeEngineBuilder, Error>(error)),
     none: error => Option.None <UpgradeEngineBuilder, Error>(error));