Skip to content

Instantly share code, notes, and snippets.

.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);
public interface ICurrentTimeProvider
{
DateTime GetCurrentTime();
}
public class CurrentTimeProvider : ICurrentTimeProvider
{
public DateTime GetCurrentTime()
{
return DateTime.UtcNow;
public class FeeCalculator
{
public const decimal DailyFee = 50.0m;
public decimal FeeFor(DateTime startTime)
{
DateTime now = ApplicationTime.Current;
if (startTime > now)
{
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>
@maniserowicz
maniserowicz / ToInvariantString
Created October 17, 2013 09:57
format any object using CultureInfo.InvariantCulture
public static string ToInvariantString(this object @this)
{
var formattable = @this as IFormattable;
if (formattable != null)
{
return formattable.ToString(null, CultureInfo.InvariantCulture);
}
return @this.ToString();
}