Skip to content

Commit

Permalink
Clean up method names
Browse files Browse the repository at this point in the history
Remove "MQTT" from general-purpose publisher methods
  • Loading branch information
wazzamatazz committed Jan 2, 2022
1 parent aed36d8 commit 4fb64c3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/NRuuviTag.Cli.Linux/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Program {

public static async Task<int> Main(string[] args) {
return await CreateHostBuilder(args)
.BuildAndRunRuuviTagMqttAgent(args)
.BuildAndRunRuuviTagPublisher(args)
.ConfigureAwait(false);
}

Expand All @@ -25,10 +25,10 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
.UseSystemd()
.UseContentRoot(AppContext.BaseDirectory)
.ConfigureAppConfiguration(config => {
config.AddRuuviTagMqttDeviceConfiguration();
config.AddRuuviTagDeviceConfiguration();
})
.ConfigureServices((hostContext, services) => {
services.AddRuuviTagMqttAgent(hostContext.Configuration, sp => ActivatorUtilities.CreateInstance<BlueZListener>(sp, BlueZListener.DefaultBluetoothAdapter));
services.AddRuuviTagPublisherCommandApp(hostContext.Configuration, sp => ActivatorUtilities.CreateInstance<BlueZListener>(sp, BlueZListener.DefaultBluetoothAdapter));
});

}
Expand Down
6 changes: 3 additions & 3 deletions src/NRuuviTag.Cli.Windows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ public class Program {

public static async Task<int> Main(string[] args) {
return await CreateHostBuilder(args)
.BuildAndRunRuuviTagMqttAgent(args)
.BuildAndRunRuuviTagPublisher(args)
.ConfigureAwait(false);
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseContentRoot(AppContext.BaseDirectory)
.ConfigureAppConfiguration(config => {
config.AddRuuviTagMqttDeviceConfiguration();
config.AddRuuviTagDeviceConfiguration();
})
.ConfigureServices((hostContext, services) => {
services.AddRuuviTagMqttAgent<WindowsSdkListener>(hostContext.Configuration);
services.AddRuuviTagPublisherCommandApp<WindowsSdkListener>(hostContext.Configuration);
});

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class NRuuviTagConfigurationBuilderExtensions {
/// <exception cref="ArgumentNullException">
/// <paramref name="builder"/> is <see langword="null"/>.
/// </exception>
public static IConfigurationBuilder AddRuuviTagMqttDeviceConfiguration(this IConfigurationBuilder builder) {
public static IConfigurationBuilder AddRuuviTagDeviceConfiguration(this IConfigurationBuilder builder) {
if (builder == null) {
throw new ArgumentNullException(nameof(builder));
}
Expand Down
2 changes: 1 addition & 1 deletion src/NRuuviTag.Cli/NRuuviTagHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static class NRuuviTagHostBuilderExtensions {
/// <exception cref="ArgumentNullException">
/// <paramref name="args"/> is <see langword="null"/>.
/// </exception>
public static async Task<int> BuildAndRunRuuviTagMqttAgent(this IHostBuilder builder, IEnumerable<string> args) {
public static async Task<int> BuildAndRunRuuviTagPublisher(this IHostBuilder builder, IEnumerable<string> args) {
if (builder == null) {
throw new ArgumentNullException(nameof(builder));
}
Expand Down
8 changes: 4 additions & 4 deletions src/NRuuviTag.Cli/NRuuviTagServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.Extensions.DependencyInjection {
public static class NRuuviTagServiceCollectionExtensions {

/// <summary>
/// Registers services required for a <see cref="CommandApp"/> that will run an <see cref="NRuuviTag.Mqtt.MqttAgent"/>.
/// Registers services required for a <see cref="CommandApp"/> that will run a <see cref="NRuuviTag.RuuviTagPublisher"/>.
/// </summary>
/// <typeparam name="TListener">
/// The <see cref="IRuuviTagListener"/> that the agent will use to listen for RuuviTag
Expand All @@ -39,7 +39,7 @@ public static class NRuuviTagServiceCollectionExtensions {
/// <exception cref="ArgumentNullException">
/// <paramref name="configuration"/> is <see langword="null"/>.
/// </exception>
public static IServiceCollection AddRuuviTagMqttAgent<TListener>(this IServiceCollection services, IConfiguration configuration) where TListener : class, IRuuviTagListener {
public static IServiceCollection AddRuuviTagPublisherCommandApp<TListener>(this IServiceCollection services, IConfiguration configuration) where TListener : class, IRuuviTagListener {
if (services == null) {
throw new ArgumentNullException(nameof(services));
}
Expand Down Expand Up @@ -85,7 +85,7 @@ public static IServiceCollection AddRuuviTagMqttAgent<TListener>(this IServiceCo
/// <exception cref="ArgumentNullException">
/// <paramref name="factory"/> is <see langword="null"/>.
/// </exception>
public static IServiceCollection AddRuuviTagMqttAgent<TListener>(this IServiceCollection services, IConfiguration configuration, Func<IServiceProvider, TListener> factory) where TListener : class, IRuuviTagListener {
public static IServiceCollection AddRuuviTagPublisherCommandApp<TListener>(this IServiceCollection services, IConfiguration configuration, Func<IServiceProvider, TListener> factory) where TListener : class, IRuuviTagListener {
if (services == null) {
throw new ArgumentNullException(nameof(services));
}
Expand All @@ -102,7 +102,7 @@ public static IServiceCollection AddRuuviTagMqttAgent<TListener>(this IServiceCo

services.AddSingleton(typeResolver);
services.AddTransient<IMqttFactory, MqttFactory>();
services.AddTransient<IRuuviTagListener, TListener>();
services.AddTransient<IRuuviTagListener, TListener>(factory);
services.AddSingleton(CommandUtilities.BuildCommandApp(typeResolver));

return services;
Expand Down
2 changes: 1 addition & 1 deletion src/NRuuviTag.Cli/TypeResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace NRuuviTag.Cli {

/// <summary>
/// Implements both <see cref="ITypeRegistrar"/> and <see cref="ITypeResolver"/> for use in the
/// MQTT publisher <see cref="CommandApp"/>.
/// RuuviTag publisher <see cref="CommandApp"/>.
/// </summary>
public class TypeResolver : ITypeRegistrar, ITypeResolver {

Expand Down

0 comments on commit 4fb64c3

Please sign in to comment.