NServiceBus.RoutingSettings.RouteToEndpoint C# (CSharp) Method

RouteToEndpoint() public method

Adds a static unicast route for all types contained in the specified assembly.
public RouteToEndpoint ( Assembly assembly, string destination ) : void
assembly System.Reflection.Assembly The assembly whose messages should be routed.
destination string Destination endpoint.
return void
        public void RouteToEndpoint(Assembly assembly, string destination)
        {
            Guard.AgainstNull(nameof(assembly), assembly);
            Guard.AgainstNullAndEmpty(nameof(destination), destination);

            ThrowOnAddress(destination);

            Settings.GetOrCreate<ConfiguredUnicastRoutes>().Add(new AssemblyRouteSource(assembly, UnicastRoute.CreateFromEndpointName(destination)));
        }

Same methods

RoutingSettings::RouteToEndpoint ( Assembly assembly, string @namespace, string destination ) : void
RoutingSettings::RouteToEndpoint ( Type messageType, string destination ) : void

Usage Example

        public void WhenPassingTransportAddressForSenderInsteadOfEndpointName_UsingAssemblyAndNamespace_ShouldThrowException()
        {
            var routingSettings = new RoutingSettings(new SettingsHolder());
            var expectedExceptionMessage = expectedExceptionMessageForWrongEndpointName;

            var exception = Assert.Throws<ArgumentException>(() => routingSettings.RouteToEndpoint(Assembly.GetExecutingAssembly(), nameof(MessageNamespaceA), "EndpointName@MyHost"));
            Assert.AreEqual(expectedExceptionMessage, exception.Message);
        }
All Usage Examples Of NServiceBus.RoutingSettings::RouteToEndpoint