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
.factory('signalr', ['$rootScope', '$timeout', function ($rootScope, $timeout) { | |
function signalrProxyFactory(hubName, startedCallback, startOptions) { | |
var connection = $.hubConnection(); | |
var proxy = connection.createHubProxy(hubName); | |
// required by SignalR to work... we need to attach at least one handler | |
// to the proxy before calling 'start' | |
proxy.on('stub', function () { }); | |
var startPromise = connection.start(startOptions); |
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
public interface ICurrentTimeProvider | |
{ | |
DateTime GetCurrentTime(); | |
} | |
public class CurrentTimeProvider : ICurrentTimeProvider | |
{ | |
public DateTime GetCurrentTime() | |
{ | |
return DateTime.UtcNow; |
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
public class FeeCalculator | |
{ | |
public const decimal DailyFee = 50.0m; | |
public decimal FeeFor(DateTime startTime) | |
{ | |
DateTime now = ApplicationTime.Current; | |
if (startTime > now) | |
{ |
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
public static class ApplicationTime | |
{ | |
private static readonly Func<DateTime> _defaultLogic = () => DateTime.UtcNow; | |
private static Func<DateTime> _current = _defaultLogic; | |
/// <summary> | |
/// Returns current date/time, correct in application context | |
/// </summary> | |
/// <remarks>Normally this would return <see cref="DateTime.UtcNow"/>, but can be changed to make testing easier.</remarks> |
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
public static string ToInvariantString(this object @this) | |
{ | |
var formattable = @this as IFormattable; | |
if (formattable != null) | |
{ | |
return formattable.ToString(null, CultureInfo.InvariantCulture); | |
} | |
return @this.ToString(); | |
} |