-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
227 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/NServiceBus.Core.Tests/Fakes/FakeCentralizedPubSubTransportDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace NServiceBus.Core.Tests.Fakes | ||
{ | ||
using Transports; | ||
|
||
public class FakeCentralizedPubSubTransportDefinition : TransportDefinition | ||
{ | ||
public FakeCentralizedPubSubTransportDefinition() | ||
{ | ||
HasNativePubSubSupport = true; | ||
HasSupportForCentralizedPubSub = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
namespace NServiceBus.Transports | ||
{ | ||
using System; | ||
using Features; | ||
using Settings; | ||
using Unicast.Transport; | ||
|
||
public abstract class ConfigureTransport<T> : Feature, IConfigureTransport<T> where T : TransportDefinition | ||
{ | ||
public void Configure(Configure config) | ||
{ | ||
var connectionString = TransportConnectionString.GetConnectionStringOrNull(); | ||
|
||
if (connectionString == null && RequiresConnectionString) | ||
{ | ||
throw new InvalidOperationException(String.Format(Message, GetConfigFileIfExists(), typeof(T).Name, ExampleConnectionStringForErrorMessage)); | ||
} | ||
|
||
SettingsHolder.Set("NServiceBus.Transport.ConnectionString", connectionString); | ||
|
||
var selectedTransportDefinition = Activator.CreateInstance<T>(); | ||
SettingsHolder.Set("NServiceBus.Transport.SelectedTransport", selectedTransportDefinition); | ||
config.Configurer.RegisterSingleton<TransportDefinition>(selectedTransportDefinition); | ||
InternalConfigure(config); | ||
} | ||
|
||
protected abstract void InternalConfigure(Configure config); | ||
|
||
protected abstract string ExampleConnectionStringForErrorMessage { get; } | ||
|
||
protected virtual bool RequiresConnectionString | ||
{ | ||
get { return true; } | ||
} | ||
|
||
|
||
static string GetConfigFileIfExists() | ||
{ | ||
return AppDomain.CurrentDomain.SetupInformation.ConfigurationFile ?? "App.config"; | ||
} | ||
|
||
const string Message = | ||
@"No default connection string found in your config file ({0}) for the {1} Transport. | ||
To run NServiceBus with {1} Transport you need to specify the database connectionstring. | ||
Here is an example of what is required: | ||
<connectionStrings> | ||
<add name=""NServiceBus/Transport"" connectionString=""{2}"" /> | ||
</connectionStrings>"; | ||
|
||
} | ||
} |
Oops, something went wrong.