Need to fix this warning 'UnicastBusConfig' is obsolete

We get the following error:

'UnicastBusConfig' is obsolete:
'Use of the application configuration file to configure the endpoint is discouraged. Use the code first API instead. Will be treated as an error from version 7.0.0. Will be removed in version 8.0.0

But how do we convert to the below code to the latest version of Nservice bus?

A class implemented IProvideConfiguration

public UnicastBusConfig GetConfiguration()
{
  return new UnicastBusConfig
  {
    MessageEndpointMappings = new MessageEndpointMappingCollection
    {
      new MessageEndpointMapping { Messages = "Messages.CreateShiftCommand, Shiftex.Messages", Endpoint = "Worker" },
      new MessageEndpointMapping { Messages = "ClaimAttemptCommand, Shiftex.Messages", Endpoint = "Worker"   }
    }
  }       
};

We saw document saying we need to use something like this

MessageEndpointMapping
 var routing = transport.Routing();
routing.RouteToEndpoint(
    assembly: typeof(AcceptOrder).Assembly,
    destination: "Sales");

but we are using
MessageEndpointMappingCollection -> MessageEndpointMapping
*Message Property *
Endpoint Property

How do convert this code to latest supported code

Could you please help

Hi @Sharath_Gowda

if CreateShiftCommand and ClaimAttemptCommand are from the same assembly (Shiftex.Messages) then what about

var routing = transport.Routing();
routing.RouteToEndpoint(
    assembly: typeof(CreateShiftCommand).Assembly,
    destination: "Worker");

or route by concrete type

var routing = transport.Routing();
routing.RouteToEndpoint(
    messageType: typeof(CreateShiftCommand),
    destination: "Worker");

routing.RouteToEndpoint(
    messageType: typeof(ClaimAttemptCommand),
    destination: "Worker");

Does this help?