예제 #1
0
 void Write(ModuleDefinition moduleDefinition, BuildSqlVariant sqlVariant, string scriptPath)
 {
     Directory.CreateDirectory(scriptPath);
     SagaWriter.WriteSagaScripts(scriptPath, moduleDefinition, sqlVariant, logError);
     TimeoutWriter.WriteTimeoutScript(scriptPath, sqlVariant);
     SubscriptionWriter.WriteSubscriptionScript(scriptPath, sqlVariant);
     OutboxWriter.WriteOutboxScript(scriptPath, sqlVariant);
 }
        public static void Write(string assemblyPath, string targetDirectory, Action <string, string> logError, Func <string, string> promotionPathFinder)
        {
            var scriptPath = Path.Combine(targetDirectory, "NServiceBus.Persistence.Sql");

            PurgeDialectDirs(scriptPath);
            Directory.CreateDirectory(scriptPath);
            Settings settings;

            using (var module = ModuleDefinition.ReadModule(assemblyPath, new ReaderParameters(ReadingMode.Deferred)))
            {
                settings = SettingsAttributeReader.Read(module);
                foreach (var dialect in settings.BuildDialects)
                {
                    var dialectPath = Path.Combine(scriptPath, dialect.ToString());
                    Directory.CreateDirectory(dialectPath);
                    if (settings.ProduceSagaScripts)
                    {
                        SagaWriter.WriteSagaScripts(dialectPath, module, dialect, logError);
                    }
                    if (settings.ProduceTimeoutScripts)
                    {
                        TimeoutWriter.WriteTimeoutScript(dialectPath, dialect);
                    }
                    if (settings.ProduceSubscriptionScripts)
                    {
                        SubscriptionWriter.WriteSubscriptionScript(dialectPath, dialect);
                    }
                    if (settings.ProduceOutboxScripts)
                    {
                        OutboxWriter.WriteOutboxScript(dialectPath, dialect);
                    }
                }
            }

            var scriptPromotionPath = settings.ScriptPromotionPath;

            if (scriptPromotionPath == null)
            {
                return;
            }
            var replicationPath = promotionPathFinder(scriptPromotionPath);

            Promote(replicationPath, scriptPath);
        }