-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
38 changed files
with
3,699 additions
and
3,750 deletions.
There are no files selected for viewing
41 changes: 19 additions & 22 deletions
41
samples/Foundatio.SampleJob/Extensions/NumberExtensions.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 |
---|---|---|
@@ -1,30 +1,27 @@ | ||
using System; | ||
namespace Foundatio.Extensions; | ||
|
||
namespace Foundatio.Extensions | ||
internal static class NumericExtensions | ||
{ | ||
internal static class NumericExtensions | ||
public static string ToOrdinal(this int num) | ||
{ | ||
public static string ToOrdinal(this int num) | ||
switch (num % 100) | ||
{ | ||
switch (num % 100) | ||
{ | ||
case 11: | ||
case 12: | ||
case 13: | ||
return num.ToString("#,###0") + "th"; | ||
} | ||
case 11: | ||
case 12: | ||
case 13: | ||
return num.ToString("#,###0") + "th"; | ||
} | ||
|
||
switch (num % 10) | ||
{ | ||
case 1: | ||
return num.ToString("#,###0") + "st"; | ||
case 2: | ||
return num.ToString("#,###0") + "nd"; | ||
case 3: | ||
return num.ToString("#,###0") + "rd"; | ||
default: | ||
return num.ToString("#,###0") + "th"; | ||
} | ||
switch (num % 10) | ||
{ | ||
case 1: | ||
return num.ToString("#,###0") + "st"; | ||
case 2: | ||
return num.ToString("#,###0") + "nd"; | ||
case 3: | ||
return num.ToString("#,###0") + "rd"; | ||
default: | ||
return num.ToString("#,###0") + "th"; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,22 +1,20 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading.Tasks; | ||
|
||
namespace Foundatio.Extensions | ||
namespace Foundatio.Extensions; | ||
|
||
internal static class TaskExtensions | ||
{ | ||
internal static class TaskExtensions | ||
[DebuggerStepThrough] | ||
public static ConfiguredTaskAwaitable<TResult> AnyContext<TResult>(this Task<TResult> task) | ||
{ | ||
[DebuggerStepThrough] | ||
public static ConfiguredTaskAwaitable<TResult> AnyContext<TResult>(this Task<TResult> task) | ||
{ | ||
return task.ConfigureAwait(continueOnCapturedContext: false); | ||
} | ||
return task.ConfigureAwait(continueOnCapturedContext: false); | ||
} | ||
|
||
[DebuggerStepThrough] | ||
public static ConfiguredTaskAwaitable AnyContext(this Task task) | ||
{ | ||
return task.ConfigureAwait(continueOnCapturedContext: false); | ||
} | ||
[DebuggerStepThrough] | ||
public static ConfiguredTaskAwaitable AnyContext(this Task task) | ||
{ | ||
return task.ConfigureAwait(continueOnCapturedContext: false); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,36 +1,33 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Foundatio.Jobs; | ||
using Foundatio.Jobs; | ||
using Foundatio.Messaging; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Foundatio.SampleJob | ||
{ | ||
public class Program | ||
{ | ||
private static ILogger _logger; | ||
namespace Foundatio.SampleJob; | ||
|
||
public static int Main() | ||
{ | ||
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); | ||
_logger = loggerFactory.CreateLogger("MessageBus"); | ||
public class Program | ||
{ | ||
private static ILogger _logger; | ||
|
||
var serviceProvider = SampleServiceProvider.Create(loggerFactory); | ||
var jobOptions = JobOptions.GetDefaults<PingQueueJob>(() => serviceProvider.GetRequiredService<PingQueueJob>()); | ||
var messageBus = serviceProvider.GetRequiredService<IMessageBus>(); | ||
messageBus.SubscribeAsync<EchoMessage>(m => HandleEchoMessage(m)).GetAwaiter().GetResult(); | ||
return new JobRunner(jobOptions).RunInConsoleAsync().GetAwaiter().GetResult(); | ||
} | ||
public static int Main() | ||
{ | ||
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); | ||
_logger = loggerFactory.CreateLogger("MessageBus"); | ||
|
||
private static void HandleEchoMessage(EchoMessage m) | ||
{ | ||
_logger.LogInformation($"Got message: {m.Message}"); | ||
} | ||
var serviceProvider = SampleServiceProvider.Create(loggerFactory); | ||
var jobOptions = JobOptions.GetDefaults<PingQueueJob>(() => serviceProvider.GetRequiredService<PingQueueJob>()); | ||
var messageBus = serviceProvider.GetRequiredService<IMessageBus>(); | ||
messageBus.SubscribeAsync<EchoMessage>(m => HandleEchoMessage(m)).GetAwaiter().GetResult(); | ||
return new JobRunner(jobOptions).RunInConsoleAsync().GetAwaiter().GetResult(); | ||
} | ||
|
||
public class EchoMessage | ||
private static void HandleEchoMessage(EchoMessage m) | ||
{ | ||
public string Message { get; set; } | ||
_logger.LogInformation($"Got message: {m.Message}"); | ||
} | ||
} | ||
|
||
public class EchoMessage | ||
{ | ||
public string Message { get; set; } | ||
} |
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
Oops, something went wrong.